From 2aefbdc31bdb5e87f5be769dea9bf3d86ed1a8eb Mon Sep 17 00:00:00 2001 From: Han <1985708279@qq.com> Date: Tue, 22 Apr 2025 13:50:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90m=E3=80=91=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=97=B6=E6=B8=85=E7=A9=BA=E9=9D=99=E6=80=81?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../04.AudioCore/RunTime/Base/AudioSourcePool.cs | 7 ++----- .../04.AudioCore/RunTime/Base/CoroutineHelper.cs | 16 ++++++++++++++-- Assets/04.AudioCore/package.json | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Assets/04.AudioCore/RunTime/Base/AudioSourcePool.cs b/Assets/04.AudioCore/RunTime/Base/AudioSourcePool.cs index 036707e..76b0542 100644 --- a/Assets/04.AudioCore/RunTime/Base/AudioSourcePool.cs +++ b/Assets/04.AudioCore/RunTime/Base/AudioSourcePool.cs @@ -24,7 +24,7 @@ namespace Stary.Evo.AudioCore } CoroutineHelper.SetRunner(); - // 初始化 Voice 池(最多 1 个,可动态扩展) + // 初始化 Voice 池(初始 1 个,可动态扩展) poolDict["Voice"] = new Queue(); CreateAudioSource("Voice"); @@ -37,10 +37,7 @@ namespace Stary.Evo.AudioCore // 初始化 SFX 池(初始 4 个,可动态扩展) poolDict["SFX"] = new Queue(); - for (int i = 0; i < 4; i++) - { - CreateAudioSource("SFX"); - } + CreateAudioSource("SFX"); } /// diff --git a/Assets/04.AudioCore/RunTime/Base/CoroutineHelper.cs b/Assets/04.AudioCore/RunTime/Base/CoroutineHelper.cs index c9436d5..965d266 100644 --- a/Assets/04.AudioCore/RunTime/Base/CoroutineHelper.cs +++ b/Assets/04.AudioCore/RunTime/Base/CoroutineHelper.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using UnityEngine; using UnityEngine.Internal; @@ -23,6 +24,17 @@ namespace Stary.Evo.AudioCore coroutineRunner.StopCoroutine(myCoroutine); } - private class CoroutineRunner : MonoBehaviour { } + private class CoroutineRunner : MonoBehaviour + { + private void OnDestroy() + { + if (coroutineRunner != null) + { + coroutineRunner.StopAllCoroutines(); + coroutineRunner = null; + } + + } + } } } diff --git a/Assets/04.AudioCore/package.json b/Assets/04.AudioCore/package.json index a1d8a90..6ef1998 100644 --- a/Assets/04.AudioCore/package.json +++ b/Assets/04.AudioCore/package.json @@ -1,6 +1,6 @@ { "name": "com.staryevo.audiocore", - "version": "1.0.3", + "version": "1.0.4", "displayName": "04.AudioCore", "description": "音频播放工具", "unity": "2021.3", From d2b9b32fe3ed2f71ef90f56cbb45f2712bff9441 Mon Sep 17 00:00:00 2001 From: Han <1985708279@qq.com> Date: Tue, 22 Apr 2025 14:17:02 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90M=E3=80=91Rokid=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AddInteraction/RKAddInteraction.cs | 24 +++++++++---------- Assets/07.RKTools/package.json | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Assets/07.RKTools/RunTime/AddInteraction/RKAddInteraction.cs b/Assets/07.RKTools/RunTime/AddInteraction/RKAddInteraction.cs index 56afc77..598d5ea 100644 --- a/Assets/07.RKTools/RunTime/AddInteraction/RKAddInteraction.cs +++ b/Assets/07.RKTools/RunTime/AddInteraction/RKAddInteraction.cs @@ -4,7 +4,7 @@ using Rokid.UXR.Interaction; using Stary.Evo; using UnityEngine; -public abstract class RKAddInteraction : MonoBehaviour +public static class RKAddInteractionExtension { #region 触摸 /// @@ -12,7 +12,7 @@ public abstract class RKAddInteraction : MonoBehaviour /// /// 被触碰物体 /// 触碰后事件 - public virtual void ObjectAddTouchEvent(GameObject Touchedobject, System.Action TouchEvent, float TouchScale = 1.2f) + public static void ObjectAddTouchEvent(this GameObject Touchedobject, System.Action TouchEvent, float TouchScale = 1.2f) { Collider ObjectCollider = Touchedobject.GetComponent(); GrabInteractable GrabInteractable = Touchedobject.GetComponent(); @@ -37,7 +37,7 @@ public abstract class RKAddInteraction : MonoBehaviour /// 暂停触摸事件 /// /// 被触碰物体 - public virtual void ObjectPauseTouchEvent(GameObject Touchedobject) + public static void ObjectPauseTouchEvent(this GameObject Touchedobject) { Collider ObjectCollider = Touchedobject.GetComponent(); if (ObjectCollider != null) @@ -50,7 +50,7 @@ public abstract class RKAddInteraction : MonoBehaviour /// 恢复触摸事件 /// /// 被触碰物体 - public virtual void ObjectResumeTouchEvent(GameObject Touchedobject) + public static void ObjectResumeTouchEvent(this GameObject Touchedobject) { Collider ObjectCollider = Touchedobject.GetComponent(); if (ObjectCollider != null) @@ -64,14 +64,14 @@ public abstract class RKAddInteraction : MonoBehaviour /// /// 被触碰物体 - public virtual void ObjectRemoveTouchEvent(GameObject Touchedobject) + public static void ObjectRemoveTouchEvent(this GameObject Touchedobject) { GrabInteractable GrabInteractable = Touchedobject.GetComponent(); if (GrabInteractable != null) { GrabInteractable.OnHoverBegin.RemoveAllListeners(); - Destroy(GrabInteractable); + Object.Destroy(GrabInteractable); } } @@ -84,7 +84,7 @@ public abstract class RKAddInteraction : MonoBehaviour /// /// 被拖动物体 /// 拖动时执行的方法 - public virtual void objectAddDrag(GameObject Dragedobject, System.Action DragingEvent = null, float DragScale = 1.2f) + public static void objectAddDrag(this GameObject Dragedobject, System.Action DragingEvent = null, float DragScale = 1.2f) { Collider ObjectCollider = Dragedobject.GetComponent(); GrabInteractable GrabInteractable = Dragedobject.GetComponent(); @@ -122,7 +122,7 @@ public abstract class RKAddInteraction : MonoBehaviour /// 暂停拖动 /// /// - public virtual void objectPauseDrag(GameObject Dragedobject) + public static void objectPauseDrag(this GameObject Dragedobject) { Collider ObjectCollider = Dragedobject.GetComponent(); if (ObjectCollider!= null) ObjectCollider.enabled = false; @@ -132,21 +132,21 @@ public abstract class RKAddInteraction : MonoBehaviour /// 恢复拖动 /// /// - public virtual void objectResumeDrag(GameObject Dragedobject) + public static void objectResumeDrag(this GameObject Dragedobject) { Collider ObjectCollider = Dragedobject.GetComponent(); if (ObjectCollider!= null) ObjectCollider.enabled = true; } - public virtual void objectRemoveDrag(GameObject Dragedobject) + public static void objectRemoveDrag(this GameObject Dragedobject) { Throwable Throwable = Dragedobject.GetComponent(); GrabInteractable GrabInteractable = Dragedobject.GetComponent(); - if (Throwable != null) Destroy(Throwable); + if (Throwable != null) Object.Destroy(Throwable); if (GrabInteractable != null) { GrabInteractable.OnHeldUpdate.RemoveAllListeners(); - Destroy(GrabInteractable); + Object.Destroy(GrabInteractable); } } #endregion diff --git a/Assets/07.RKTools/package.json b/Assets/07.RKTools/package.json index ff9b23a..7596d0a 100644 --- a/Assets/07.RKTools/package.json +++ b/Assets/07.RKTools/package.json @@ -1,6 +1,6 @@ { "name": "com.staryevo.rktools", - "version": "1.0.0", + "version": "1.0.1", "displayName": "07.RKTools", "description": "Rokid工具", "unity": "2021.3", From 442e6920625237406d623433f6694542d99d6af8 Mon Sep 17 00:00:00 2001 From: Han <1985708279@qq.com> Date: Tue, 22 Apr 2025 17:06:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90m=E3=80=91=E9=9D=99=E6=80=81?= =?UTF-8?q?=E7=BD=AE=E7=A9=BA=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/04.AudioCore/RunTime/Use/AudioCoreManager.cs | 8 +++++--- Assets/04.AudioCore/package.json | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Assets/04.AudioCore/RunTime/Use/AudioCoreManager.cs b/Assets/04.AudioCore/RunTime/Use/AudioCoreManager.cs index ac919c0..213bac0 100644 --- a/Assets/04.AudioCore/RunTime/Use/AudioCoreManager.cs +++ b/Assets/04.AudioCore/RunTime/Use/AudioCoreManager.cs @@ -9,8 +9,8 @@ namespace Stary.Evo.AudioCore private static VoicePlayer Voice; private static SFXPlayer SFX; private static MusicPlayer Music; - - static AudioCoreManager() + + public static void Initialize() { audioSourcePool = new AudioSourcePool(); // 初始化播放器 @@ -18,7 +18,6 @@ namespace Stary.Evo.AudioCore SFX = new SFXPlayer(audioSourcePool); Music = new MusicPlayer(audioSourcePool); } - #region 语音 /// @@ -28,6 +27,7 @@ namespace Stary.Evo.AudioCore /// [onComplete:回调行为], [delayOnCompleteTime:延迟回调执行的时间]} public static void PlayVoice(AudioData audioData) { + if(Voice == null) Initialize(); Voice.Play(audioData); } @@ -51,6 +51,7 @@ namespace Stary.Evo.AudioCore /// [onComplete:回调行为], [delayOnCompleteTime:延迟回调执行的时间]} public static void PlaySFX(AudioData audioData) { + if(SFX == null) Initialize(); SFX.Play(audioData); } @@ -73,6 +74,7 @@ namespace Stary.Evo.AudioCore /// {[clip:音频], [volume:音量], [fadeDuration:自然过渡时间]} public static void PlayMusic(AudioData audioData) { + if(Music == null) Initialize(); Music.Play(audioData); } diff --git a/Assets/04.AudioCore/package.json b/Assets/04.AudioCore/package.json index 6ef1998..f0347d3 100644 --- a/Assets/04.AudioCore/package.json +++ b/Assets/04.AudioCore/package.json @@ -1,6 +1,6 @@ { "name": "com.staryevo.audiocore", - "version": "1.0.4", + "version": "1.0.5", "displayName": "04.AudioCore", "description": "音频播放工具", "unity": "2021.3",