I have added a UI Toggle to my main menu in order to mute the game audio on click. Everything works fine but the only problem is that no matter whether the Audio Listener volume is on 0 or 1, the checkbox is always shown when the main menu opens. How do I only make the checkbox appear when Audio Listener Volume is 1?
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class checkb : MonoBehaviour {
public Toggle toggle;
public AudioSource audioSrs;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(audioSrs.volume>=1) {
toggle.isOn=true;
} else {
toggle.isOn=false;
}
}
}