// The Awake function of each class is called before the Start function. It is // here you should initialise class properties/variables like those above. void Awake() { // Get the Animator off the game object this script is attached to as // we'll need it later switchAnimator = gameObject.GetComponent <Animator>(); GameObject theBulb = GameObject.FindGameObjectWithTag("Bulb"); if (theBulb != null) { theBulbController = theBulb.GetComponent <BulbController>(); } }
// Update is called once per frame void Update() { if (!isReady) { if (battery != null && bulb != null && resistor != null && toggle != null ) { isReady = true; batteryController = battery.GetComponent <ElectricalElementController>(); bulbController = bulb.GetComponent <BulbController>(); resistorController = resistor.GetComponent <ElectricalElementController>(); toggleController = toggle.GetComponent <ToggleController>(); setupLevel(); } } else { Electrify(); } }