From 71b40afcc77997a61e6165470f3aea2abf2bd0ea Mon Sep 17 00:00:00 2001 From: uhu Date: Mon, 21 Nov 2022 20:44:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20js=E6=89=A7=E8=A1=8C=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Demo/API/Assets/Scripts/AudioManager.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Demo/API/Assets/Scripts/AudioManager.cs b/Demo/API/Assets/Scripts/AudioManager.cs index 87f026e..3134ec0 100644 --- a/Demo/API/Assets/Scripts/AudioManager.cs +++ b/Demo/API/Assets/Scripts/AudioManager.cs @@ -326,11 +326,22 @@ public class AudioManager : MonoBehaviour } // 长音频在使用后需要销毁 audioBGM = createAudio(); + // audioBGM.loop = true; audioBGM.src = audioList[index]; audioBGM.OnCanplay(() => { audioBGM.Play(); }); + // 自动播放停止 + audioBGM.OnEnded(() => + { + audioBGM = null; + }); + // 手动停止 + audioBGM.OnStop(() => + { + audioBGM = null; + }); } // 销毁场景 -- GitLab