【发布时间】:2014-12-24 14:38:16
【问题描述】:
我正在使用 Unity 4.6 制作自己的游戏。我一直在播放背景音乐。但我想让我的玩家可以通过简单的切换使音乐静音。 我正在使用 C#。有人对如何做到这一点有任何想法吗?
会很有帮助! 我就是这样解决的!
using UnityEngine;
using System.Collections;
public class Mute: MonoBehaviour{
bool isMute;
public void MusicMute (){
if(isMute == true){
Debug.Log("Music On");
AudioListener.volume = 1;
isMute = false;
}
else {
Debug.Log("Music Off");
isMute = true;
AudioListener.volume = 0;
}
}
}
【问题讨论】: