Search Unity

Calling a not-defined-in-script scripts function from inside another script

Discussion in 'Scripting' started by serkale, Jun 30, 2015.

  1. serkale

    serkale

    Joined:
    Jun 17, 2015
    Posts:
    15
    Basically what I'm trying to do is recieve a pointer to a script (B)'s function from outside the main script (A) (kind of like in the UI button) so that script B's function can be called as a result of running a function in script A.

    Something like this (taken from UI button):
    Screen Shot 2015-06-29 at 4.48.15 PM.png

    How would I go about scripting this?

    Thanks!
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    not that that description makes huge amounts of sense... but are you talking about using UnityEvents? (google that)
     
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Simply expose a UnityEvent to the inspector.