更改 AudioSource 音量
Changing AudioSource volume
我正在尝试更改我的 AudioSource
GameObject
音量,正如文档所述,它只是 myAudioSourceGameObject.volume = 0.5f
.
但是,在我的脚本中我无法访问任何名为 volume
的字段。
那么您应该如何通过代码更改 AudioSource
的音量?
制作音频源
AudioSource asour;
分配它,然后更改它
asour.volume = 0.5f;
好的,我知道了。
public GameObject go = GameObject.Find("MyGameObjectAudioSource");
void Update()
{
go.GetComponent<AudioSource>().volume = 0.5f;
}
感谢大家的帮助。
public gameobject MainCamera;
MainCamera.GetComponent<AudioSource>().volume = 0.7f;
这里 MainCamera 被称为 GameObject...
我正在尝试更改我的 AudioSource
GameObject
音量,正如文档所述,它只是 myAudioSourceGameObject.volume = 0.5f
.
但是,在我的脚本中我无法访问任何名为 volume
的字段。
那么您应该如何通过代码更改 AudioSource
的音量?
制作音频源
AudioSource asour;
分配它,然后更改它
asour.volume = 0.5f;
好的,我知道了。
public GameObject go = GameObject.Find("MyGameObjectAudioSource");
void Update()
{
go.GetComponent<AudioSource>().volume = 0.5f;
}
感谢大家的帮助。
public gameobject MainCamera;
MainCamera.GetComponent<AudioSource>().volume = 0.7f;
这里 MainCamera 被称为 GameObject...