gpt4 book ai didi

unity3d - 统一使用主菜单中的 slider 停止所有场景的音频

转载 作者:行者123 更新时间:2023-12-03 00:27:23 24 4
gpt4 key购买 nike

统一使用主菜单中的 slider 停止所有场景的音频

我在不同的场景中使用不同的声音,但问题是我无法使用菜单中的 slider 停止所有声音,它只是停止菜单声音或场景声音,但是当我的游戏结束菜单按钮出现时,我点击了它,然后听起来像我一样我在后台脚本中使用 DontDestroyOnLoad

公共(public)类 BGSoundScript:MonoBehaviour {

// Use this for initialization
void Start () {
audioSrc = GetComponent<AudioSource>();
}

//Play Global
private static BGSoundScript instance = null;
public static BGSoundScript Instance
{
get { return instance; }
}

void Awake()
{
if (instance != null && instance != this)
{
Destroy(this.gameObject);
return;
}
else
{
instance = this;
}

DontDestroyOnLoad(this.gameObject);
}
public void SetVolume(float vol)
{
musicVolume = vol;
}
//Play Gobal End

}

//我正在使用 BGSoundScript.Instance.audioSrc.Play();和//BGSoundScript.Instance.audioSrc.Pause();在其他脚本中,但那也不是//对我有用

最佳答案

使用音频混合器。这里有一个关于混音器的小教程:https://www.youtube.com/watch?v=vOaQp2x-io0

关于unity3d - 统一使用主菜单中的 slider 停止所有场景的音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55782382/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com