Advertisement
Guest User

Untitled

a guest
Aug 15th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class on : MonoBehaviour {
  5.     public AudioClip soundOn;  
  6.    
  7.    
  8.     // Update is called once per frame
  9.     void Update () {
  10.         if(Input.GetKeyDown (KeyCode.Mouse1))
  11.         {
  12.             if(GetComponent<Light>().enabled == false)
  13.             {
  14.                 GetComponent<Light>().enabled = true;
  15.                 GetComponent<AudioSource>().Play();
  16.             }
  17.             else
  18.             {
  19.                 GetComponent<Light>().enabled = false;
  20.                 GetComponent<AudioSource>().Play();
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement