Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    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. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Simple question about UnityEvents

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

  1. PrimeDerektive

    PrimeDerektive

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