Play this article
Inspector > Add Component
By default, when you create a new MonoBehaviour
component, it is added to the menu under Scripts/{namespace}/{component} and gets jumbled in with a lot of other random stuff from packages you have imported.
Default Example
namespace PlayableDesign.ThriftShop
{
public class CameraController : MonoBehaviour
{
}
}
Menu
Yuck!
AddComponentMenu
Instead, you can create a custom folder at the top level of the context menu in the editor using the AddComponentMenu
attribute.
Better Example
[AddComponentMenu("Custom/" + nameof(CameraController))]
public class CameraController : MonoBehaviour
{
}
Menu
Best Example
Even better, I like to use dashes as the folder name so that my components are always on top.
[AddComponentMenu("-----/" + nameof(CameraController))]
public class CameraController : MonoBehaviour
{
}
Menu