- Home /
Question by
B-R-J · Jan 30, 2018 at 04:22 PM ·
scripting problemeventsystemevent triggering
get object that uses the event trigger
I have attached an Onclick Event trigger on a Gameobject (A) , which calls a function of a script, which is attached to a different GameObject (B). In this function, I need to get the object that has the OnClick trigger (A) . Is it possible to implement this in Unity without making reference variables to A in B's script?
Comment
Answer by Obsessi0n · Feb 01, 2018 at 10:04 AM
You either make a reference on script B to A, or on the GameObjectA trigger sends a parameter reference to itself so on the function in B it receives the trigger with a parameter with the reference to A.
When I get home I can try to get an example so I can try to explain it better.
Yep, was about to say, why have B look for A when A can tell B everything it needs.