diff --git a/Source/Editor/CustomEditors/Editors/GenericEditor.cs b/Source/Editor/CustomEditors/Editors/GenericEditor.cs index a20b41f8c..7e5118496 100644 --- a/Source/Editor/CustomEditors/Editors/GenericEditor.cs +++ b/Source/Editor/CustomEditors/Editors/GenericEditor.cs @@ -261,6 +261,7 @@ namespace FlaxEditor.CustomEditors.Editors public static List GetItemsForType(ScriptType type, bool useProperties, bool useFields, bool usePropertiesWithoutSetter = false) { var items = new List(); + var isPlayMode = Editor.IsPlayMode; if (useProperties) { @@ -278,7 +279,7 @@ namespace FlaxEditor.CustomEditors.Editors continue; // Skip hidden fields, handle special attributes - if ((!p.IsPublic && !showInEditor) || attributes.Any(x => x is HideInEditorAttribute)) + if ((!p.IsPublic && !showInEditor) || attributes.Any(x => x is HideInEditorAttribute hide && (!isPlayMode || !hide.ShowInPlayMode))) continue; items.Add(new ItemInfo(p, attributes)); @@ -293,11 +294,10 @@ namespace FlaxEditor.CustomEditors.Editors for (int i = 0; i < fields.Length; i++) { var f = fields[i]; - var attributes = f.GetAttributes(true); // Skip hidden fields, handle special attributes - if ((!f.IsPublic && !attributes.Any(x => x is ShowInEditorAttribute)) || attributes.Any(x => x is HideInEditorAttribute)) + if ((!f.IsPublic && !attributes.Any(x => x is ShowInEditorAttribute)) || attributes.Any(x => x is HideInEditorAttribute hide && (!isPlayMode || !hide.ShowInPlayMode))) continue; items.Add(new ItemInfo(f, attributes)); diff --git a/Source/Engine/Scripting/Attributes/Editor/HideInEditorAttribute.cs b/Source/Engine/Scripting/Attributes/Editor/HideInEditorAttribute.cs index b306d84d7..79b6acf34 100644 --- a/Source/Engine/Scripting/Attributes/Editor/HideInEditorAttribute.cs +++ b/Source/Engine/Scripting/Attributes/Editor/HideInEditorAttribute.cs @@ -10,6 +10,11 @@ namespace FlaxEngine [Serializable] public sealed class HideInEditorAttribute : Attribute { + /// + /// Shows the variable only in play mode (when the game is running), otherwise it will be hidden. Useful for runtime fields or properties to remain invisible at edit time. + /// + public bool ShowInPlayMode; + /// /// Initializes a new instance of the class. ///