diff --git a/Editor/Drawers/CustomObjectDrawer.cs b/Editor/Drawers/CustomObjectDrawer.cs index b1931f2..5b6b27e 100644 --- a/Editor/Drawers/CustomObjectDrawer.cs +++ b/Editor/Drawers/CustomObjectDrawer.cs @@ -94,6 +94,7 @@ private void HandleMouseDown(Rect position, Rect positionWithoutThumb) else if (Event.button == 1 && positionWithoutThumb.Contains(Event.mousePosition)) { GenericMenu menu = new GenericMenu(); + menu.AddItem(new GUIContent("Clear"), false, () => { DeletePressed?.Invoke(); }); menu.AddItem(new GUIContent("Properties..."), false, () => { PropertiesClicked?.Invoke(); }); menu.DropDown(position); Event.Use(); diff --git a/Editor/Items/NoneDropdownItem.cs b/Editor/Items/NoneDropdownItem.cs new file mode 100644 index 0000000..63e4431 --- /dev/null +++ b/Editor/Items/NoneDropdownItem.cs @@ -0,0 +1,16 @@ +using UnityEditor.IMGUI.Controls; + +namespace TNRD.Items +{ + public class NoneDropdownItem : AdvancedDropdownItem, IDropdownItem + { + public NoneDropdownItem() : base("None") { } + + ReferenceMode IDropdownItem.Mode => ReferenceMode.Raw; + + public object GetValue() + { + return null; + } + } +} diff --git a/Editor/Items/NoneDropdownItem.cs.meta b/Editor/Items/NoneDropdownItem.cs.meta new file mode 100644 index 0000000..2813776 --- /dev/null +++ b/Editor/Items/NoneDropdownItem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a7015062205d46cbb9cb01b0b88fff55 +timeCreated: 1657572673 \ No newline at end of file diff --git a/Editor/Utilities/SerializableInterfaceAdvancedDropdown.cs b/Editor/Utilities/SerializableInterfaceAdvancedDropdown.cs index af82ecd..923d03a 100644 --- a/Editor/Utilities/SerializableInterfaceAdvancedDropdown.cs +++ b/Editor/Utilities/SerializableInterfaceAdvancedDropdown.cs @@ -48,6 +48,11 @@ protected override AdvancedDropdownItem BuildRoot() .AddChild(new ClassesItemBuilder(interfaceType).Build()) .AddChild(new SceneItemBuilder(interfaceType, relevantScene).Build()); + foreach (AdvancedDropdownItem dropdownItem in item.children) + { + dropdownItem.AddChild(new NoneDropdownItem()); + } + if (canSort) { sortChildrenMethod.Invoke(item, @@ -62,6 +67,12 @@ protected override AdvancedDropdownItem BuildRoot() private int Sort(AdvancedDropdownItem a, AdvancedDropdownItem b) { + // For aesthetic reasons. Always puts the None first + if (a is NoneDropdownItem) + return -1; + if (b is NoneDropdownItem) + return 1; + int childrenA = a.children.Count(); int childrenB = b.children.Count();