【m】停止运行时清空静态对象

This commit is contained in:
Han
2025-04-22 13:50:46 +08:00
parent 8c5d3f412d
commit 2aefbdc31b
3 changed files with 17 additions and 8 deletions

View File

@@ -24,7 +24,7 @@ namespace Stary.Evo.AudioCore
}
CoroutineHelper.SetRunner();
// 初始化 Voice 池(最多 1 个,可动态扩展)
// 初始化 Voice 池(初始 1 个,可动态扩展)
poolDict["Voice"] = new Queue<GameObject>();
CreateAudioSource("Voice");
@@ -37,11 +37,8 @@ namespace Stary.Evo.AudioCore
// 初始化 SFX 池(初始 4 个,可动态扩展)
poolDict["SFX"] = new Queue<GameObject>();
for (int i = 0; i < 4; i++)
{
CreateAudioSource("SFX");
}
}
/// <summary>
/// 创建对象

View File

@@ -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;
}
}
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "com.staryevo.audiocore",
"version": "1.0.3",
"version": "1.0.4",
"displayName": "04.AudioCore",
"description": "音频播放工具",
"unity": "2021.3",