mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 16:28:23 -05:00
34 lines
1.2 KiB
C#
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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|