void Start()
 {
     if (devicesController == null)
     {
         devicesController = GetComponentInParent <ElectricDevicesController>();
     }
     if (device == null)
     {
         device = GetComponentInParent <ElectricDevice>();
     }
 }
Beispiel #2
0
    //var time_event = new Tuple<long, float>(0,0.0f);

    //public List<Tuple<long, float>> Pattern;

    // Use this for initialization
    void Start()
    {
        if (devicesController == null)
        {
            devicesController = GetComponentInParent <ElectricDevicesController>();
        }

        Deselect();
        StopHover();

        //_pilotView = PilotView.GetInstance(); // David

        //This is used for replacing a material
        //We initially save the gameobjects materials to the side in order to be able to switch back to them.
        foreach (Runlevel rl in runlevels)
        {
            //Energy effeciency runlevels
            rl.SetPowerByEE(energyEffeciency);

            //Materials

            //Maybe we have a specifically targeted renderer (of a gameObject) that we want to affect
            Renderer rend = rl.Target;

            //If target not set, use the gameobjects renderer
            if (rend == null)
            {
                rend = gameObject.GetComponent <Renderer>();
            }


            if (rend == null)
            {
                //Apparently the object doesn't have a renderer
                continue;
            }
            //Shouldn't be null at this point!
            Debug.Assert(rend != null);

            rl.Default_materials = (Material[])rend.sharedMaterials;
        }

        base.Start();
        //lastupdate = _timeMgr.time;

        //Set initial runlevel.
        SetRunlevel(runlevel);
    }