Search Unity

Multiple variables Event (UnityEvent<T0,T1>,UnityEvent<T0,T1,T2>,UnityEvent<T0,T1,T2,T3)

Discussion in 'Scripting' started by mexicano, Dec 2, 2018.

  1. mexicano

    mexicano

    Joined:
    Nov 12, 2013
    Posts:
    23
    Hi, I am trying to make a custom event so I can send more than 1 variable to a function. I know unity has compatibility with UnityEnvent to up to 4 variables but I can't figure how it works.
    I don't understand how it works. when I assign the functions all the fields are empty.
    There is a doc on unity but I can't even make the example one to work
    https://docs.unity3d.com/ScriptReference/Events.UnityEvent_2.html

    I have created some custom shelves for unity to work with the base event class but I don't understand the custom one.
    Can someone post an example code that works so I can see how it's done?
    like, name class and script inside. (any call like print(x+y) with x and y input in the event function )