- Home /
How can I hide a MonoBehaviour from the Inspector? (or make it extremely thin or compact)
Hi,
I need to have separate and multiple MonoBehaviours on a single GameObject, and I also have a "grouping" component which handles them.
Probably I did a poor design choice but, anyway, also for future use, is there a way to hide a component in the inspector? (side question: renaming it, changing the label background color, etc,)
Should I use some complex reflection gimmick to obtain this? Maybe is there some undocumented feature? I'm pretty new to reflection and custom editors, so any suggestion is welcome.
Answer by roojerry · Jan 20, 2017 at 09:18 PM
Check out HideFlags
HideFlags only relate to object visibility. As far as I'm aware, there's no equivalent to control component visibility.
You sure?
I just tested by adding
this.hideFlags = HideFlags.HideInInspector;
to Start or Awake of a $$anonymous$$onoBehaviour, and it hides the component at runtime
You're absolutely right, it does work for components too - I never knew!
Duh, I thought about it but assumed it only worked for gameobjects!
But... Will I still be able to reference them in a list of monobehaviour in the same object?
Your answer
Follow this Question
Related Questions
How to check if reflected inspector field is empty 1 Answer
How do I get the grid layout component? 0 Answers
I'm having trouble getting the text in Unity's "text mesh" to change its text at runtime. 1 Answer
Error while using SerializeField and HideInInspector tags 0 Answers
Can you hide a custom icon for a script in the scene view? 0 Answers