- Home /
Hide Unity Events in Custom Inspector
Hi there, i have got some public unity events which i want to show/hide in a custom inspector by checking/unchecking a bool in the same inspector. How can i hide unity events in a custom inspector?
Greets
Answer by itchyOwl · Feb 05, 2018 at 01:29 PM
If you create a custom inspector for a MonoBehaviour script, you can choose to not inherit the defaults by omitting base.OnInspectorGUI() in the OnInspectorGUI() callback. Then you have to create all the displayed fields by yourself. For the toggle functionality, there are EditorGUILayout.Toggle and EditorGUI.Toggle classes in the UnityEditor namespace.
If you do use the default inspector, you can either use [HideInInspector] tag or leave the field private (in the script, not the editor script). It's the same for any serializable types, not just UnityEvents.
Your answer
