Tri-Inspector/Editor.Extras/Drawers/CustomBuiltInDrawer.cs

34 lines
1.2 KiB
C#

using TriInspector;
using TriInspector.Drawers;
using TriInspector.Elements;
using TriInspector.Utilities;
using TriInspectorUnityInternalBridge;
[assembly: RegisterTriValueDrawer(typeof(CustomBuiltInDrawer), TriDrawerOrder.Fallback - 999)]
namespace TriInspector.Drawers
{
public class CustomBuiltInDrawer : TriValueDrawer<object>
{
public override TriElement CreateElement(TriValue<object> propertyValue, TriElement next)
{
var property = propertyValue.Property;
if (property.TryGetSerializedProperty(out var serializedProperty))
{
var handler = ScriptAttributeUtilityProxy.GetHandler(serializedProperty);
var drawWithHandler = handler.hasPropertyDrawer ||
property.PropertyType == TriPropertyType.Primitive ||
TriUnityInspectorUtilities.MustDrawWithUnity(property);
if (drawWithHandler)
{
return new TriBuiltInPropertyElement(property, serializedProperty, handler);
}
}
return base.CreateElement(propertyValue, next);
}
}
}