|
Sorry if this is too obvious, I'm still trying to learn how to scipt. Here's the problem I'm having. I have three boxes in the scene called box1, box2, box3. These boxes are in a gameobject array variable within a script that's attached to the camera. Now each of these boxes have a script attached to them that switches a bool to off if I mouse over the box. My question is, how do I access this script that's attached to these boxes through the script that's attached to the camera and within the array that these boxes are held at. I usually use a GameObject.Find to find info for one object, but never had to do it within an array. Any help would be great thanks!
(comments are locked)
|
|
So long as you have a reference to the gameobject or transform (which it sounds like you have with your mouseover functionality), you can simply use GetComponent to get a reference to the component/script you want: http://unity3d.com/support/documentation/ScriptReference/Component.GetComponent.html
(comments are locked)
|
|
In your camera script, probably have Note you can pre-fetch the components of those boxes in a Start script so you don't have to GetComponent each time.
(comments are locked)
|
|
This script can called any tag"box" in gameObject script.
(comments are locked)
|
