# How to display custom UnityEvents in the editor?

I recently stumbled upon the UnityEngine.Events.UnityEvent class, and it seemed pretty cool so I started using it in a project.

Then I decided that I wanted to add some parameters to the event using its generic variants, like so:

[System.Serializable]
public class BarkEvent<GameObject> : UnityEvent<GameObject> {}

public class MyOtherClass : MonoBehavior {
public BarkEvent<GameObject> bark;
// ... Other stuff ...
}


But now it doesn't show up in the editor, making it harder to wire up my subscribers. Is there a way to make unity events with extra arguments show up in the Unity editor?

• Try changing BarkEvent<GameObject> to just BarkEvent in both instances. I can't really try this out but if this works, please try and turn it into an answer :) Apr 13 '17 at 5:59

@JohnHamilton is right. Because Unity can't serialize generic types in the inspector (not easily, workarounds exist I think), your event won't be displayed. The purpose of inheriting from the UnityEvent type is to get rid of the generic type and be able to serialize it in order to be shown in the inspector.

Your event is "designed" to handle GameObjects only, thus, you don't have (and should not) specify the GameObject type between the chevrons.

[System.Serializable]
public class BarkEvent : UnityEvent<GameObject> {}

public class MyOtherClass : MonoBehavior {
public BarkEvent bark;

public void YourFunction()
{
if( bark != null )
brak.Invoke( gameobject ) ;
}
}