using System; using UnityEngine; using UnityEngine.Audio; public class TestSound : MonoBehaviour { void Start() { } void Update() { } public AudioClip audioClip1; public AudioClip audioClip2; private int i = 0; private void OnTriggerEnter(Collider other) { Debug.Log("Trigger Detected with " + other.gameObject.name); AudioSource audio = GetComponent(); // audio.PlayOneShot(audioClip); // float audioTime = audioClip.length; // GameObject.Destroy(gameObject,audioTime); i++; if (i%2 == 0) // Managers.Sound.Play("UnityChan/univ0001",Define.Sound.Bgm); Managers.Sound.Play(audioClip1,Define.Sound.Bgm); else // Managers.Sound.Play("UnityChan/univ0002",Define.Sound.Bgm); Managers.Sound.Play(audioClip2,Define.Sound.Bgm); } }