I have a GUI button and when it is clicked I want it to activate an animation by calling another script. How do I do that?
Thanks for your help!
I have a GUI button and when it is clicked I want it to activate an animation by calling another script. How do I do that?
Thanks for your help!
To access other scripts, you need to find the GameObject that they are attached to, and the Component of that GameObject.
In C#:
Component OtherScript = GameObject.Find("gameobject").GetComponent<script>();
Please note, script name is not in quotes.
You can then do things like OtherScript.function();
In your OnGUI() function, add
if(GUI.Button(new Rect(50f,50f,100f,30f), "buttonText")){
OtherScript.function();
}