接着相關資料1的內容,刪除其中CubeJump調用Play3DSound的AnimationEvent。
添加一個UIButton
在視圖中,鼠標右鍵UI-Button新建一個UIButton按鈕,其Button組件的OnClick()添加一個事件,CubeJump.SendMessage事件,填寫Play3DSound。
AnimationEvent可以調用私有函數。
.SendMessage函數可以調用 該腳本的 私有函數。
.SendMessage可以通過UI的Button的OnClick函數來進行使用,也可以在代碼中直接使用。
參考資料:
1.Unity3D中的SendMessage使用(消息推送)
2.
相關資料:
1.[Unity][聲音][Animation]代碼控制3D實體播放動畫發出3D聲音
2.