Search Unity

Manual callbacks with TriggerEvent?

Discussion in 'Scripting' started by quinnbot, Sep 18, 2014.

  1. quinnbot

    quinnbot

    Joined:
    Sep 18, 2014
    Posts:
    10
    Hello! I'd like to invoke callbacks in a way similar to EventTrigger, but not in response to any of the existing events. Instead I would like to set up the callbacks via the Inspector and then trigger them in response to a game action. Got most of the way there (i think) but I just cant figure out how to actually make Unity execute the callback.

    First I started off with this code in my class:
    Code (CSharp):
    1. public UnityEngine.EventSystems.EventTrigger.TriggerEvent myCallback;
    Which as you can see produces the expected UI in the Inspector:


    I then dragged in the object which has all the various scripts I'd like to execute and picked an appropriate one:


    Looks good, right....

    ... but now that I have this TriggerEvent loaded with the correct callback (confirmed in debugger, too), I cannot figure how the code to actually invoke it. TriggerEvent itself appears to have no function which does this and I am at a loss for where else to look.

    How can I get Unity to invoke this callback?
     

    Attached Files:

  2. quinnbot

    quinnbot

    Joined:
    Sep 18, 2014
    Posts:
    10
    *crickets*
     
  3. quinnbot

    quinnbot

    Joined:
    Sep 18, 2014
    Posts:
    10
    FYI - I did manage to hack this using EventTriggers. So at least I have a way to drag and drop callbacks in the inspector. But its a pretty bad hack - was really hoping someone would have insight into how to do it properly.