At the moment using this,
#pragma strict
function OnMouseDown() {
//Turns off yellow
var yellow = GameObject.Find("Yellow(Clone)");
while (yellow != null)
{
yellow.SetActive(true);
yellow = GameObject.Find("Yellow(Clone)");
}
Debug.Log("Took off yellow");
//Turns on green
var green = GameObject.Find("GreenSwitch(Clone)");
while (green != null)
{
green.SetActive(false);
green = GameObject.Find("GreenSwitch(Clone)");
}
}
But this is highly unefficient because when an object is turned on that needs to be activated, the game freezes.
Any other ideas?
↧