using UnityEngine;

public class PersistentAudio : MonoBehaviour {
    public int StopAtScene = 100;
    private AudioSource _audio;
    
    void Awake () {
        _audio = GetComponent<AudioSource>();
        DontDestroyOnLoad(gameObject);
    }

    private void OnLevelWasLoaded(int level)
    {
        if (level >= StopAtScene)
        {
            _audio.Stop();
            Destroy(gameObject);
        }
    }
}
