From 2d70e79f0364cc2da299d6e3cec823aeb0b59da0 Mon Sep 17 00:00:00 2001 From: VladV Date: Wed, 25 Oct 2023 18:34:50 +0400 Subject: [PATCH] Now UIToolkit support is opt-in --- Editor.Extras/Drawers/CustomBuiltInDrawer.cs | 18 +++++++++++------- Runtime/Attributes/DrawWithUnityAttribute.cs | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Editor.Extras/Drawers/CustomBuiltInDrawer.cs b/Editor.Extras/Drawers/CustomBuiltInDrawer.cs index 9ec70a92..c4514ade 100644 --- a/Editor.Extras/Drawers/CustomBuiltInDrawer.cs +++ b/Editor.Extras/Drawers/CustomBuiltInDrawer.cs @@ -25,15 +25,19 @@ public override TriElement CreateElement(TriValue propertyValue, TriElem if (drawWithHandler) { - handler.SetPreferredLabel(property.DisplayName); + if (property.TryGetAttribute(out DrawWithUnityAttribute withUnityAttribute) && + withUnityAttribute.WithUiToolkit) + { + handler.SetPreferredLabel(property.DisplayName); - var visualElement = handler.CreatePropertyGUI(serializedProperty); + var visualElement = handler.CreatePropertyGUI(serializedProperty); - if (visualElement != null && - TriEditorCore.UiElementsRoots.TryGetValue(property.PropertyTree, out var rootElement)) - { - return new TriUiToolkitPropertyElement(property, serializedProperty, - visualElement, rootElement); + if (visualElement != null && + TriEditorCore.UiElementsRoots.TryGetValue(property.PropertyTree, out var rootElement)) + { + return new TriUiToolkitPropertyElement(property, serializedProperty, + visualElement, rootElement); + } } return new TriBuiltInPropertyElement(property, serializedProperty, handler); diff --git a/Runtime/Attributes/DrawWithUnityAttribute.cs b/Runtime/Attributes/DrawWithUnityAttribute.cs index 4e13b90f..a357df08 100644 --- a/Runtime/Attributes/DrawWithUnityAttribute.cs +++ b/Runtime/Attributes/DrawWithUnityAttribute.cs @@ -7,5 +7,6 @@ namespace TriInspector [Conditional("UNITY_EDITOR")] public class DrawWithUnityAttribute : Attribute { + public bool WithUiToolkit { get; set; } } } \ No newline at end of file