From d0f7a04c589be00a817a730c29b113e4f20d9f29 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 24 Nov 2023 14:59:07 +0100 Subject: [PATCH] Add support for getter-only properties in blackboard selector access --- .../CustomEditors/Editors/BehaviorKnowledgeSelectorEditor.cs | 4 +++- Source/Editor/CustomEditors/Editors/GenericEditor.cs | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Editor/CustomEditors/Editors/BehaviorKnowledgeSelectorEditor.cs b/Source/Editor/CustomEditors/Editors/BehaviorKnowledgeSelectorEditor.cs index 8ac6a51cb..b3c5792ac 100644 --- a/Source/Editor/CustomEditors/Editors/BehaviorKnowledgeSelectorEditor.cs +++ b/Source/Editor/CustomEditors/Editors/BehaviorKnowledgeSelectorEditor.cs @@ -171,11 +171,13 @@ namespace FlaxEditor.CustomEditors.Editors tree.Select(typeNode); if (addItems) { - var items = GenericEditor.GetItemsForType(type, type.IsClass, true); + var items = GenericEditor.GetItemsForType(type, type.IsClass, true, true); foreach (var item in items) { if (typed && !typed.IsAssignableFrom(item.Info.ValueType)) continue; + if (item.Info.DeclaringType.Type == typeof(FlaxEngine.Object)) + continue; // Skip engine internals var itemPath = typePath + item.Info.Name; var node = new TreeNode { diff --git a/Source/Editor/CustomEditors/Editors/GenericEditor.cs b/Source/Editor/CustomEditors/Editors/GenericEditor.cs index 55ac453a9..68c24a675 100644 --- a/Source/Editor/CustomEditors/Editors/GenericEditor.cs +++ b/Source/Editor/CustomEditors/Editors/GenericEditor.cs @@ -247,8 +247,9 @@ namespace FlaxEditor.CustomEditors.Editors /// The type. /// True if use type properties. /// True if use type fields. + /// True if use type properties that have only getter method without setter method (aka read-only). /// The items. - public static List GetItemsForType(ScriptType type, bool useProperties, bool useFields) + public static List GetItemsForType(ScriptType type, bool useProperties, bool useFields, bool usePropertiesWithoutSetter = false) { var items = new List(); @@ -264,7 +265,7 @@ namespace FlaxEditor.CustomEditors.Editors var showInEditor = attributes.Any(x => x is ShowInEditorAttribute); // Skip properties without getter or setter - if (!p.HasGet || (!p.HasSet && !showInEditor)) + if (!p.HasGet || (!p.HasSet && !showInEditor && !usePropertiesWithoutSetter)) continue; // Skip hidden fields, handle special attributes