From 7f493f682503f5186308de7b8f74b5b49233cfe4 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 2 Nov 2023 11:51:31 +0800 Subject: +init --- GameCode/PriorityAudioListener.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 GameCode/PriorityAudioListener.cs (limited to 'GameCode/PriorityAudioListener.cs') diff --git a/GameCode/PriorityAudioListener.cs b/GameCode/PriorityAudioListener.cs new file mode 100644 index 0000000..127e5fb --- /dev/null +++ b/GameCode/PriorityAudioListener.cs @@ -0,0 +1,27 @@ +using System.Collections; +using UnityEngine; + +public class PriorityAudioListener : MonoBehaviour +{ + private void OnEnable() + { + StartCoroutine(ExecuteAfterTime()); + } + + private IEnumerator ExecuteAfterTime() + { + while (BackupAudioListener.Instance == null) + { + yield return null; + } + BackupAudioListener.Instance.EnableBackupListener(enable: false); + } + + private void OnDisable() + { + if (BackupAudioListener.Instance != null) + { + BackupAudioListener.Instance.EnableBackupListener(enable: true); + } + } +} -- cgit v1.1-26-g67d0