Exemplo n.º 1
0
 public void ListenSwitch()
 {
     foreach (GameObject gameObject in this)
     {
         if (gameObject == null)
         {
             continue;
         }
         LightSwitcher switcher = gameObject.GetComponent <LightSwitcher>();
         if (switcher != null && Input.GetKeyDown(switcher.Key))
         {
             UnityEngine.Light light = gameObject.GetComponent <UnityEngine.Light>();
             light.enabled = !light.enabled;
         }
     }
 }
Exemplo n.º 2
0
        public void SetSwitch(UnityEngine.Light light, KeyCode code)
        {
            LightSwitcher switcher = light.gameObject.GetComponent <LightSwitcher>();

            if (code != KeyCode.None)
            {
                if (switcher == null)
                {
                    switcher = light.gameObject.AddComponent <LightSwitcher>();
                }
                switcher.Key = code;
            }
            else
            {
                UnityEngine.Object.DestroyImmediate(switcher);
            }
        }
Exemplo n.º 3
0
        public KeyCode GetSwitch(UnityEngine.Light light)
        {
            if (light == null)
            {
                return(KeyCode.None);
            }
            LightSwitcher switcher = light.gameObject.GetComponent <LightSwitcher>();

            if (switcher != null)
            {
                return(switcher.Key);
            }
            else
            {
                return(KeyCode.None);
            }
        }