game(scripts): normalise AudioLoop

This commit is contained in:
Mark Joshwel 2025-02-14 21:55:58 +08:00
parent 4011266881
commit b292de5922

View file

@ -3,8 +3,8 @@
Date: 10/2/2025
Description: Loop the school bell and interval
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AudioLoop : MonoBehaviour
@ -13,10 +13,7 @@ public class AudioLoop : MonoBehaviour
private void Start()
{
if (audioSource == null)
{
audioSource = GetComponent<AudioSource>();
}
if (audioSource == null) audioSource = GetComponent<AudioSource>();
StartCoroutine(PlayPauseLoop());
}
@ -24,6 +21,7 @@ public class AudioLoop : MonoBehaviour
{
StartCoroutine(PlayPauseLoop());
}
private IEnumerator PlayPauseLoop()
{
while (true)
@ -35,5 +33,8 @@ public class AudioLoop : MonoBehaviour
audioSource.Stop(); // Pause the audio
yield return new WaitForSeconds(15f); // Pause for 15 seconds
}
// NOTE: are we really just going to let this stay alive forever
// ReSharper disable once IteratorNeverReturns
}
}