using UnityEngine;
using System.Collections;
public class FlashlightToggle : MonoBehaviour {
public Light flashlight;
private bool isOn;
public AudioClip flashlightOn;
public AudioClip flashlightOff;
public AudioSource source;
void Start()
{
isOn = true;
}
void Update () {
if (Input.GetKeyDown (KeyCode.F))
{
if (isOn == false) {
flashlight.enabled = true;
isOn = true;
source.PlayOneShot(flashlightOn);
} else if (isOn == true)
{
flashlight.enabled = false;
isOn = false;
source.PlayOneShot(flashlightOff);
}
}
}
}