Search Unity

Simple question about UnityEvents

Discussion in 'Scripting' started by PrimeDerektive, May 18, 2018.

  1. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    So if I have a custom UnityEvent<t0, t1> that takes multiple arguments... In the editor I can either add "dynamic listeners" that take the same corresponding arguments, or "static parameters", which are any functions that take 0 or 1 argument (provided the argument is a standard unity type).

    I'd like to add a listener through script to my custom UnityEvent, but the listener doesn't take the parameters that are declared in the UnityEvent (it takes no parameters, its a simple function), so it fails and says it requires a function that takes the corresponding arguments.(cannot convert "method group" to "UnityAction<GameObject, GameObject>").

    You can add simple listeners through the inspector that don't have the corresponding parameters, so how do you do it in script?