void OnMouseDown() { if (!cs.getCharacterSelection()) { for (int i = 0; i < cs.characterList.Length; i++) { if (cs.characterList [i].gameObject.name == this.gameObject.name) { cs.setIndex(i); canvas.gameObject.SetActive(true); cs.setCharacterSelection(true); Debug.Log(i); } } GameObject[] lights = GameObject.FindGameObjectsWithTag("SelectionLight"); foreach (GameObject light in lights) { light.GetComponent <Light> ().enabled = false; } spotlight.GetComponent <Light> ().enabled = true; } }