- Home /
Question by
SyntaxTerror · May 08, 2018 at 09:29 AM ·
c#eventscustom-inspector
How do I expose a UnityEvent in a Custom Inspector?
I've noticed that there doesn't appear to be a way to expose a UnityEvent in a custom inspector. I have three events defined in the target class but can't find any way to expose them through the custom inspector class.
In the target class, I simply have them defined liked this:
public UnityEvent transitionStarted;
public UnityEvent transitionFinished;
public UnityEvent transitionPaused;
Of course, when I set up a custom editor for this class, it doesn't automatically expose them.
Comment
Best Answer
Answer by UnityCoach · May 08, 2018 at 02:58 PM
You can call base.DrawDefaultInspector
which will call Editor.DrawDefaultInspector
Of you can expose it using EditorGUILayout.PropertyField with a SerializedProperty pointing to your UnityEvent.
Hope this helps.
Your answer
