Hiding a MonoBehaviour in the Unity Script Component Menu

If you’re building anything substantial in Unity, you ultimately will want to use base or code-only instantiated MonoBehaviour classes. It can be a real hassle to deal with these cluttering up your script component menu in the Unity editor when you never want to access them that way.

This little gem will prevent them from showing up in the component menu.

using UnityEngine;

[AddComponentMenu("")]  // Hide this script in the editor
public class MyHiddenBehaviour : MonoBehaviour
	// Your code here

Adding the line [AddComponentMenu(“”)] as meta data before your class will prevent it from showing up in the editor.

Leave a Reply

Your email address will not be published. Required fields are marked *