Is it possible to send a custom object as a parameter of a UnityAction? In my event manager system I have UnityAction eventListener = new UnityAction(func); void func(int a){ //do summin with passed int a } I am not sure how to implement this in my current system but I do have it working without the parameters though.
UnityAction (and its Generic types) are just delegate declaractions. You can use UnityEvent to pass data around. you'll want to define a new class that has your custom class as its generic type. Code (CSharp): [System.Serializable]public class MyCustomClass{} public class CustomEvent : UnityEvent<MyCustomClass>{} public class ExampleScript : MonoBehaviour { [HideInInspector]public CustomEvent OnEvent = new CustomEvent(); private void OnEnable() { OnEvent.AddListener(MyHandler); OnEvent.Invoke(new MyCustomClass()); } private void OnDisable() { OnEvent.RemoveListener(MyHandler); } private void MyHandler(MyCustomClass data) { Debug.Log("Got the Data!"); } } If the type was a simple, serializeable type like int string float bool or UnityEngine.Object then you could link up invocations for that event in the inspector. However for custom classes, while the event will still work just fine it has very little support for you in the inspector (hence why I tagged it with [HideInInspector] in the example to avoid confusion). All it really means is that you just have to set it up via code.
I would want it to invoke a generic type so as not to be stuck with only one type of passing parameter.
then make the event pass the most abstract type needed, the handlers can then try to cast it to specific types when needed. if it can't cast then they can do nothing (return), or you can have so that depending on the type it does different things (like if a Collider is a Sphere Collider do one thing vs Box Collider do another).
I was trying to implement it to pass data between scripts without having to find gameobject or linking the scripts directly
I typically do this via ScriptableObject Events. You can find an example of this on this post. The code is written in a way so that one Monobehaviour its not coupled to another, yet instances can be linked up in the inspector (and yes this will also work on custom classes). And it also works with linking up two separate prefabs (as gone over in that thread).