mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Texture inheritance for materials, also script access
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user