Add cross button to unset abstract class or interface object value
This commit is contained in:
@@ -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("<null>");
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user