Texture inheritance for materials, also script access

This commit is contained in:
Simon Lübeß
2025-03-01 00:03:38 +01:00
parent 824c19c0b2
commit b5088329f5
13 changed files with 470 additions and 82 deletions
@@ -51,6 +51,43 @@ public static class ActivatorExtension
return null;
}
/// <summary>
/// Creates an instance of the given type inheriting from engine object and sets it's id.
/// </summary>
/// <param name="engineObjectType">The type of the engine object.</param>
/// <param name="objectId">The objects id.</param>
/// <returns>An instance of the engine object type; or <see langword="null"/> if the creation failed.</returns>
internal static EngineObject? CreateEngineObject(Type engineObjectType, UUID objectId)
{
EngineObject? engineObject = (EngineObject?)CreateInstanceSafe(engineObjectType);
if (engineObject != null)
engineObject._uuid = objectId;
return engineObject;
}
/// <summary>
/// Creates an instance of the given type inheriting from engine object and sets it's id.
/// </summary>
/// <param name="engineObjectType">The type of the engine object.</param>
/// <param name="objectId">The objects id.</param>
/// <returns>An instance of the engine object type; or <see langword="null"/> if the creation failed.</returns>
internal static T? CreateEngineObject<T>(Type engineObjectType, UUID objectId) where T : EngineObject
{
if (!typeof(T).IsAssignableFrom(engineObjectType))
{
return null;
}
EngineObject? engineObject = (EngineObject?)CreateInstanceSafe(engineObjectType);
if (engineObject != null)
engineObject._uuid = objectId;
return (T?)engineObject;
}
/// <summary>
/// Creates an instance of the given component type and sets it's entities id.
/// </summary>
+6
View File
@@ -1,5 +1,6 @@
using System;
using System.Runtime.CompilerServices;
using GlitchyEngine.Core;
using GlitchyEngine.Math;
using ImGuiNET;
@@ -74,6 +75,11 @@ public static class ImGuiExtension
ScriptGlue.ImGuiExtension_ListElementGrabber();
}
public static bool ShowAssetDropTarget(ref UUID uuid)
{
return ScriptGlue.ImGuiExtension_ShowAssetDropTarget(ref uuid);
}
public static bool Checkbox2(string label, ref bool2 value) => CheckboxN(2, label, ref value.X);
public static bool Checkbox3(string label, ref bool3 value) => CheckboxN(3, label, ref value.X);
public static bool Checkbox4(string label, ref bool4 value) => CheckboxN(4, label, ref value.X);