using UnityEngine;
public class PlayMusic: MonoBehaviour
{
[SerializeField]
private AudioClip _musicBG;
private float _timer;
void Start()
{
if (_musicBG!= null)
{
AudioSource.PlayClipAtPoint(_musicBG, Vector3.zero);
_timer = _musicBG.length;
}
}
void Update()
{
_timer = _timer - Time.deltaTime;
if(_timer<0)
{
AudioSource.PlayClipAtPoint(_musicBG, Vector3.zero);
_timer = _musicBG.length;
}
}
}