From c08ca33a9af4f935538ce118f3f7f8c600c0fa7e Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 24 Mar 2024 20:57:19 +0100 Subject: [PATCH] Fix `Revert to Default` option when property is marked as `ReadOnly` --- Source/Editor/CustomEditors/CustomEditor.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/Editor/CustomEditors/CustomEditor.cs b/Source/Editor/CustomEditors/CustomEditor.cs index ef6302e8e..48ada9150 100644 --- a/Source/Editor/CustomEditors/CustomEditor.cs +++ b/Source/Editor/CustomEditors/CustomEditor.cs @@ -385,6 +385,15 @@ namespace FlaxEditor.CustomEditors LinkedLabel = label; } + internal bool CanEditValue + { + get + { + var readOnly = Values.Info.GetAttribute(); + return readOnly == null; + } + } + /// /// If true, the value reverting to default/reference will be handled via iteration over children editors, instead of for a whole object at once. /// @@ -413,7 +422,7 @@ namespace FlaxEditor.CustomEditors { if (!Values.IsDefaultValueModified) return false; - return true; + return CanEditValue; } } @@ -422,7 +431,7 @@ namespace FlaxEditor.CustomEditors /// public void RevertToDefaultValue() { - if (!Values.HasDefaultValue) + if (!Values.HasDefaultValue || !CanEditValue) return; RevertDiffToDefault(); } @@ -471,7 +480,7 @@ namespace FlaxEditor.CustomEditors } else { - if (Values.IsReferenceValueModified) + if (CanRevertReferenceValue) SetValueToReference(); } } @@ -485,7 +494,7 @@ namespace FlaxEditor.CustomEditors { if (!Values.IsReferenceValueModified) return false; - return true; + return CanEditValue; } } @@ -494,7 +503,7 @@ namespace FlaxEditor.CustomEditors /// public void RevertToReferenceValue() { - if (!Values.HasReferenceValue) + if (!Values.HasReferenceValue || !CanEditValue) return; RevertDiffToReference(); }