- Home /
Question by
Chazzwazzler · Nov 13, 2020 at 10:19 PM ·
c#editorunityeditoreditor-scripting
Is it possible for me to add new objects in the thing that comes up when you right click in the heirarchy?
Is it possible to add new objects that you spawn in the editor with an editor script or something? If so, how would I code it? I mainly want to know because I am making some generic prefabs that would be really nice to quickly spawn via this right click menu.
image-2020-11-13-151655.png
(112.4 kB)
Comment
Best Answer
Answer by Zubzuke · Nov 13, 2020 at 11:03 PM
You can use attributes in your C# scripts:
[CreateAssetMenu(fileName = "New Scriptable Object", menuName = "Create My Scriptable Object")]
public class MySO : ScriptableObject
{
}
or
[ContextMenuItem("Do something", "SomeFunction")]
private void SomeFunction()
{
}
You can check out more C# attributes in the Unity script reference:
https://docs.unity3d.com/ScriptReference/AddComponentMenu.html