private IEnumerator Play() { yield return(new WaitUntil(() => IsAudioPlayerReady)); if (AudioPlayerToUse == null) { Debug.LogError("PlayAmbientAudio does not have AudioPlayer assigned.", this); yield break; } if (AudioPlayerToUse.Clips.Count == 0) { yield break; } int index = UseRandomClip ? Random.Range(0, AudioPlayerToUse.Clips.Count) : ClipIndex; if (index == -1) { Debug.LogError("No clip is selected in PlayAmbientAudio", this); yield break; } _handle = AudioPlayerToUse.Play(index, tracking: _trackingTarget); }
public void OnPointerClick(PointerEventData eventData) { if (!_play) { return; } if (!IsAudioPlayerReady) { Debug.LogWarning($"AudioPlayer was not ready. Could not play audio on click of {gameObject.name}"); return; } if (AudioPlayerToUse == null) { Debug.LogError("PlayAudioOnClick does not have AudioPlayer assigned.", this); return; } if (AudioPlayerToUse.Clips.Count == 0) { return; } int index = UseRandomClip ? Random.Range(0, AudioPlayerToUse.Clips.Count) : ClipIndex; if (index == -1) { Debug.LogError("No clip is selected in PlayAudioOnClick", this); return; } AudioPlayerToUse.Play(index); }