// Start is called before the first frame update void Start() { _waterControlScript = GetAttachedControlScript(); if (_waterControlScript == null) { throw new UnityException("Problem finding water control script in " + gameObject.name); } }
Water_Controls GetAttachedControlScript() { Transform parent = transform.parent; for (int i = 0; i < parent.childCount; ++i) { if (parent.GetChild(i).gameObject.tag == "Steam Valve Pipe") { Water_Controls _controlScript = parent.GetChild(i).gameObject.GetComponent <Water_Controls>(); return(_controlScript); } } return(null); }
public void Awake() { Water_Controls = new Water_Controls(); BindInputs(); }