Skip to content

Commit 50401ca

Browse files
committed
Implemented functionality to exclude a class from generating a menu item
1 parent 3b53d01 commit 50401ca

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Editor/ScriptableObjectContainerEditor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ void GetScriptableObjectTypes(List<System.Type> result)
609609
continue;
610610
if (!a.allowSubClass && t != a.type)
611611
continue;
612+
if (a.excludeThisClass && t == a.type)
613+
continue;
612614
supportsType = true;
613615
break;
614616
}

Runtime/Attributes/CreateSubAssetMenuAttribute.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ public bool allowSubClass
3535
set;
3636
}
3737

38+
/// <summary>
39+
/// Whether to create a menu item for the <see cref="type"/> specifically. It's useful when you add
40+
/// the <see cref="CreateSubAssetMenuAttribute"/> to a base-class where you want all sub-classes to
41+
/// have menu items generated for, except for the base-class.
42+
/// </summary>
43+
public bool excludeThisClass
44+
{
45+
get;
46+
set;
47+
}
48+
3849
/// <summary>
3950
/// The display name for this type shown in the "Add Object" menu.
4051
/// If <see cref="menuName"/> is empty, it uses the type name instead.

0 commit comments

Comments
 (0)