private void Start() { BehaviourScript = gameObject.GetComponent <RobotBehaviourScript>(); if (BehaviourScript == null) { throw new NullReferenceException("Could not find a RobotBehaviourScript on " + gameObject.name); } }
/// <summary> /// Helper method to get the index of the for loop start /// </summary> private int GetIndexOfScript(RobotBehaviourScript script) { for (int i = 0; i < GetComponents <RobotBehaviourScript>().Length; i++) { if (GetComponents <RobotBehaviourScript>()[i] == script) { return(i); } } throw new KeyNotFoundException(); }