how to access a method declared inside a script attached to child of another gameobject?
i want to invoke a method which is inside a script which is attached to the child of another gameobject. how can i invoke it from a script which is not on the same gameobject?
Answer by sparkinfo · Sep 01, 2016 at 02:19 AM
i guess i figured it out on my own :) first i created an instance of the target script like this:
public targetscript variablename;
then in the hierarchy i dragged the gameobject which had my targetscript attached to it into the empty field of the current script.
and then i simply did variablename.methodname();
Your answer
Follow this Question
Related Questions
Objects are created in the same location. 0 Answers
Suggest best hosting server for multiplayer Game??? 0 Answers
Trying to transform my character's local position on a GetKey. 0 Answers
How to toggle elements within a prefab in Unity 0 Answers
How do i use lines to calculate triangles on mesh?? 0 Answers