gameObject.GetComponents("MyScript").BooleanVariable = true;
Now for the people who look at that like "wtf?"
Here's a simple way to understand that;
Say I need Unity to find my computer and turn the power buttton to on, in a Java or UnityScript environment I would tell unity
MyHouse.MyRoom.Desk.Computer.PowerButton = on;
So to access a script named PowerButton on a gameobject named computer and change the Boolean variable powerButton to an on state we'd approach it like this;
GameObject.Find("computer").GetComponent("PowerButton").powerButton = true;
I saw this explanation awhile ago and it really helped me teach myself how make things happen in Unity.
No comments:
Post a Comment