Question by
HaleyHat · Aug 20, 2016 at 06:22 AM ·
audiosourcemouseclickvolumeaudiolistenermute
How to start audio clip on mute then click mouse button to unmute without disrupting clip time? Then click again to mute again all while audio clip remains on loop.
I'm not very good at code but this is what I have so far. Seems like it is playing the audio clip at the beginning and then the mute box clicks on and off but I can't figure out how to adjust the audio listener to go to "1" when it is "unmuted"
using UnityEngine;
using System.Collections;
public class VolumeControl : MonoBehaviour {
AudioSource audio;
void Start() {
audio = GetComponent<AudioSource>();
AudioListener.volume = 0F;
}
void Update() {
GetComponent<AudioSource>().Play();
AudioListener.volume = 0F;
if (Input.GetKeyDown("mouse 0"))
if (audio.mute)
audio.mute = false;
else
audio.mute = true;
}
}
Comment