ClientServer/Client/Assets/Scripts/Util/AudioAutoDestroy.cs

17 lines
415 B
C#
Raw Normal View History

2025-09-06 17:17:39 +04:00
using UnityEngine;
//thomas09
//edited script to not destroy the object now. Since it is pooled.
public class AudioAutoDestroy : MonoBehaviour
{
private AudioSource audioSource;
private void Awake() => audioSource = GetComponent<AudioSource>();
private void Update()
{
if (!audioSource.isPlaying)
{
AudioManager.Instance.DisableSource(audioSource);
}
}
}