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
+37
View File
@@ -12,6 +12,7 @@ using System.Runtime.InteropServices;
using System.Text;
using GlitchyEngine.Core;
using GlitchyEngine.Extensions;
using GlitchyEngine.Graphics;
using GlitchyEngine.Math;
using GlitchyEngine.Math.Attributes;
using ImGuiNET;
@@ -570,6 +571,10 @@ internal class EntityEditor
{
newValue = ShowComponentDropTarget(fieldName, fieldType, reference, attributes);
}
else if (fieldType.IsSubclassOf(typeof(Asset)))
{
newValue = ShowAssetDropTarget(fieldName, fieldType, reference, attributes);
}
else if (fieldType == typeof(string))
{
newValue = ShowStringEditor(reference, fieldType, fieldName, attributes);
@@ -864,6 +869,38 @@ internal class EntityEditor
return newValue;
}
private static object? ShowAssetDropTarget(string fieldName, Type fieldType, object? currentValue, IEnumerable<Attribute>? attributes)
{
object? newValue = DidNotChange;
string fieldId = StartNewProperty(fieldName, attributes);
Asset? asset = currentValue as Asset;
UUID uuid = asset?.UUID ?? UUID.Zero;
if (ImGuiExtension.ShowAssetDropTarget(ref uuid))
{
if (uuid == UUID.Zero)
{
newValue = null;
}
else
{
try
{
newValue = ActivatorExtension.CreateEngineObject(fieldType, uuid);
}
catch (Exception e)
{
Log.Exception(e);
}
}
}
return newValue;
}
private static object? ShowEntityDropTarget(string fieldName, Type fieldType, object? currentValue, IEnumerable<Attribute>? attributes)
{
object? newValue = DidNotChange;