Spaces:
Sleeping
Sleeping
File size: 693 Bytes
defab59 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | using UnityEngine;
public class DinoAmbientLoop : MonoBehaviour
{
public AudioSource ambientSource;
public AudioClip ambientClip;
public float volume = 0.35f;
void Awake()
{
if (ambientSource == null)
{
ambientSource = gameObject.AddComponent<AudioSource>();
ambientSource.loop = true;
ambientSource.playOnAwake = false;
ambientSource.spatialBlend = 0f;
}
}
void Start()
{
if (ambientClip == null || ambientSource == null)
return;
ambientSource.clip = ambientClip;
ambientSource.volume = Mathf.Clamp01(volume);
ambientSource.Play();
}
}
|