From 7eb8291c31e2618ce255c2e460d763572e5e9b04 Mon Sep 17 00:00:00 2001 From: Alexejhero <32238504+Alexejhero@users.noreply.github.com> Date: Mon, 6 Nov 2023 06:26:30 +0200 Subject: [PATCH] Fix TooltipAttribute not working and expose TriEditor.OnEnable and TriEditor.OnDisable (#144) --- Editor/Editors/TriEditor.cs | 4 ++-- Editor/Elements/TriLabelElement.cs | 9 +++++++-- Editor/TriPropertyDefinition.cs | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Editor/Editors/TriEditor.cs b/Editor/Editors/TriEditor.cs index f70718a..e49a35c 100644 --- a/Editor/Editors/TriEditor.cs +++ b/Editor/Editors/TriEditor.cs @@ -7,12 +7,12 @@ namespace TriInspector.Editors { private TriEditorCore _core; - private void OnEnable() + protected virtual void OnEnable() { _core = new TriEditorCore(this); } - private void OnDisable() + protected virtual void OnDisable() { _core.Dispose(); } diff --git a/Editor/Elements/TriLabelElement.cs b/Editor/Elements/TriLabelElement.cs index eb0c163..6c028c1 100644 --- a/Editor/Elements/TriLabelElement.cs +++ b/Editor/Elements/TriLabelElement.cs @@ -6,9 +6,14 @@ namespace TriInspector.Elements { private readonly GUIContent _label; - public TriLabelElement(string label) + public TriLabelElement(string label, string tooltip = "") { - _label = new GUIContent(label); + _label = new GUIContent(label, tooltip); + } + + public TriLabelElement(GUIContent label) + { + _label = label; } public override float GetHeight(float width) diff --git a/Editor/TriPropertyDefinition.cs b/Editor/TriPropertyDefinition.cs index 75cdcb0..493a6be 100644 --- a/Editor/TriPropertyDefinition.cs +++ b/Editor/TriPropertyDefinition.cs @@ -102,6 +102,10 @@ namespace TriInspector { CustomTooltip = ValueResolver.ResolveString(this, tooltipAttribute.Tooltip); } + else if (Attributes.TryGet(out TooltipAttribute unityTooltipAttribute)) + { + CustomTooltip = new ConstantValueResolver(unityTooltipAttribute.tooltip); + } } public Type OwnerType { get; }