From 55a756532b855d2ae388500a02cf4d78e6623e98 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 22 Jul 2026 11:30:49 +0200 Subject: [PATCH] Add cross button to unset abstract class or interface object value --- Source/Editor/CustomEditors/Editors/GenericEditor.cs | 8 +++++++- .../CustomEditors/Elements/Container/GroupElement.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Editor/CustomEditors/Editors/GenericEditor.cs b/Source/Editor/CustomEditors/Editors/GenericEditor.cs index fb16a1d56..0d8f949ec 100644 --- a/Source/Editor/CustomEditors/Editors/GenericEditor.cs +++ b/Source/Editor/CustomEditors/Editors/GenericEditor.cs @@ -707,10 +707,10 @@ namespace FlaxEditor.CustomEditors.Editors if (!HasDifferentTypes) { var value = Values[0]; + var type = Values.Type; if (value == null) { // Check if it's an object type that can be created in editor - var type = Values.Type; if (type != ScriptMemberInfo.Null) { ScriptType[] types = null; @@ -754,6 +754,12 @@ namespace FlaxEditor.CustomEditors.Editors layout.Label(""); return; } + if (!type.IsArray && !type.IsStructure && !type.IsScriptingObject && (type.IsAbstract || type.IsInterface) && value.GetType() != type.Type && layout is GroupElement group) + { + // Add button to unset the value to null (eg. to edit it to different type) + var button = group.AddHeaderButton("Reset value to null", 0, FlaxEngine.GUI.Style.Current.Cross); + button.Clicked += (_, _) => SetValue(null); + } items = GetItemsForType(TypeUtils.GetObjectType(value)); } diff --git a/Source/Editor/CustomEditors/Elements/Container/GroupElement.cs b/Source/Editor/CustomEditors/Elements/Container/GroupElement.cs index a3397d10a..79ce070c0 100644 --- a/Source/Editor/CustomEditors/Elements/Container/GroupElement.cs +++ b/Source/Editor/CustomEditors/Elements/Container/GroupElement.cs @@ -55,7 +55,7 @@ namespace FlaxEditor.CustomEditors.Elements const float padding = 2.0f; var settingsButtonSize = Panel.HeaderHeight; Panel.HeaderTextMargin = Panel.HeaderTextMargin with { Right = settingsButtonSize + Utilities.Constants.UIMargin }; -; return new Image + return new Image { TooltipText = tooltipText, AutoFocus = true,