2022-12-07 01:44:11 -05:00
|
|
|
|
using TriInspector;
|
|
|
|
|
using TriInspector.Drawers;
|
2023-07-29 05:08:53 -04:00
|
|
|
|
using TriInspector.Editors;
|
2022-12-07 01:44:11 -05:00
|
|
|
|
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)
|
|
|
|
|
{
|
2023-10-25 10:34:50 -04:00
|
|
|
|
if (property.TryGetAttribute(out DrawWithUnityAttribute withUnityAttribute) &&
|
|
|
|
|
withUnityAttribute.WithUiToolkit)
|
|
|
|
|
{
|
|
|
|
|
handler.SetPreferredLabel(property.DisplayName);
|
2023-10-15 04:56:15 -04:00
|
|
|
|
|
2023-10-25 10:34:50 -04:00
|
|
|
|
var visualElement = handler.CreatePropertyGUI(serializedProperty);
|
2023-07-29 05:08:53 -04:00
|
|
|
|
|
2023-10-25 10:34:50 -04:00
|
|
|
|
if (visualElement != null &&
|
|
|
|
|
TriEditorCore.UiElementsRoots.TryGetValue(property.PropertyTree, out var rootElement))
|
|
|
|
|
{
|
|
|
|
|
return new TriUiToolkitPropertyElement(property, serializedProperty,
|
|
|
|
|
visualElement, rootElement);
|
|
|
|
|
}
|
2023-07-29 05:08:53 -04:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 01:44:11 -05:00
|
|
|
|
return new TriBuiltInPropertyElement(property, serializedProperty, handler);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.CreateElement(propertyValue, next);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|