Unity:无法更改音频源OnClick UI按钮?

时间:2016-09-10 05:59:13

标签: c# audio unity5

我想将AudioSource(Clicksound)更改为其他AudioSource(DrumSound) 当游戏过程中点击ui按钮时。代码运行但是AudioSource的更改从不会从ClickSound更改为Drumsound,下面是我使用的代码

AudioSource Sound;
public AudioSource DrumSound;
public AudioSource ClickSound;

void Start () {

    Sound = ClickSound;
    Time.timeScale = 0;

}

public void drumClicked()
{
    Sound = DrumSound;
    SettingCanvas.SetActive (false);
}
public void OnTriggerEnter2D(Collider2D col)
{
    if (col.tag == "Piviot" && Time.timeScale != 0) {
        Sound.Play ();
    }
}

0 个答案:

没有答案