- Home /
Duplicate Question
Plugging a script into another script when gameobject is selecte
Hi so currently in my project what i need to do is be able to select a gameobject and then once it's selected have the gameManager script then grab the script from the selected gameobject so that it can then compare its value's with another selected script. sorry if i havent explained myself very clearly
Answer by robertbu · Oct 03, 2013 at 07:08 AM
When a script is attached to a game object it is called a component of that game object. Typically getting access to any component is a two step process. First identifying the game object, then get the component from that game object. Here are a couple of references:
http://docs-jp.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html
http://docs-jp.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Components.html