From c3f7e8949e554c69c19db3a8f6045ca3ba742ee9 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Mon, 30 Dec 2024 20:55:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3webgl=E9=9F=B3=E9=A2=91?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResKit/Scripts/LocalAudioSupport.cs | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Assets/QFramework/Toolkits/ResKit/Scripts/LocalAudioSupport.cs b/Assets/QFramework/Toolkits/ResKit/Scripts/LocalAudioSupport.cs index bd027002..025d12cc 100644 --- a/Assets/QFramework/Toolkits/ResKit/Scripts/LocalAudioSupport.cs +++ b/Assets/QFramework/Toolkits/ResKit/Scripts/LocalAudioSupport.cs @@ -3,6 +3,7 @@ namespace QFramework using UnityEngine; using System.Collections; using UnityEngine.Networking; + using UnityEngine.Rendering; public static class LocalAudioResUtil { @@ -192,9 +193,30 @@ namespace QFramework } else { - // Convert the downloaded data to an AudioClip + // ȴ + while (!request.downloadHandler.isDone) + { + yield return null; + } + + + // ɺתΪ AudioClip AudioClip clip = DownloadHandlerAudioClip.GetContent(request); - mAsset = clip; + + if (clip != null) + { + // Ƶ״̬ + while (clip.loadState != AudioDataLoadState.Loaded) + { + yield return null; + } + + mAsset = clip; // Ƶɺֵ mAsset + } + else + { + Debug.LogError("Failed to load audio clip."); + } } if (RefCount <= 0)