From e4eb4dab4702e4e8032dd91bd4a5c67fb77721e4 Mon Sep 17 00:00:00 2001 From: Anders Ejlersen Date: Sat, 4 Dec 2021 14:25:57 +0100 Subject: [PATCH] Added obsolete text to tooltip (only works, if another property attribute is present) --- Editor/AbstractPropertyDrawer.cs | 1 - Editor/Utilities/EditorPropertyUtility.cs | 20 +++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Editor/AbstractPropertyDrawer.cs b/Editor/AbstractPropertyDrawer.cs index 37f0a48..1879be4 100644 --- a/Editor/AbstractPropertyDrawer.cs +++ b/Editor/AbstractPropertyDrawer.cs @@ -24,7 +24,6 @@ namespace Module.Inspector.Editor bool prevEnabled = GUI.enabled; GUI.enabled = accessType == EAccessType.Enabled; - // TODO: What to do with [Obsolete]? if (result.draw != null) { diff --git a/Editor/Utilities/EditorPropertyUtility.cs b/Editor/Utilities/EditorPropertyUtility.cs index 38c0cef..b830539 100644 --- a/Editor/Utilities/EditorPropertyUtility.cs +++ b/Editor/Utilities/EditorPropertyUtility.cs @@ -126,14 +126,24 @@ namespace Module.Inspector.Editor.Utilities } } - if (!string.IsNullOrEmpty(obsoleteText)) + if (isObsolete) { - if (tooltip != null) - tooltip += $"\n[Obsolete: {obsoleteText}"; + if (string.IsNullOrEmpty(obsoleteText)) + { + if (tooltip != null) + tooltip += $"\n[Obsolete]"; + else + tooltip = $"[Obsolete]"; + } else - tooltip = $"Obsolete: {obsoleteText}"; + { + if (tooltip != null) + tooltip += $"\n[Obsolete: {obsoleteText}]"; + else + tooltip = $"[Obsolete: {obsoleteText}]"; + } } - + return new Result(drawer, predrawerModifiers, valueModifiers, accessModifiers, tooltip, isObsolete); }