Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Simple question about UnityEvents

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

  1. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,068
    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?