public void SetActive(bool active) { //Lazy load used to solve race condition. Not ideal, but good enough for now if (targets == null) { Initialize(); } if (active) { activeTarget = targets[0]; activeTarget.gameObject.SetActive(true); } else if (activeTarget != null) { activeTarget.gameObject.SetActive(false); } }
public void NextTarget() { activeTarget.gameObject.SetActive(false); activeTarget = targets[++targetCounter % targets.Length]; activeTarget.gameObject.SetActive(true); }