/// <summary> /// Plays the specified event once on a <see cref="NonSpatialAudioSource"/>. /// </summary> /// <param name="evt">The event to play</param> public Playback PlayNonSpatial(AudioEvent evt) { var source = this.nonSpatialAudioSources.Get(); source.gameObject.SetActive(true); Playback playback = Play(evt, source, PlaybackType.NONSPATIAL); return(playback); }
/// <summary> /// Plays the specified event once on the specified player gameobject. /// This will make the playback audio source be parented to player at origin position and identity rotation. /// /// Note that this method is not doing any spatial playback configuration on the audio source _at all_. /// The audio event should do the spatial setup. /// </summary> /// <param name="evt">The event to play</param> /// <param name="player">The object which is playing the event.</param> /// <returns>Playback information</returns> public Playback PlayWorldspace(AudioEvent evt, GameObject player) { var source = this.worldspaceAudioSources.Get(); source.gameObject.SetActive(true); Playback playback = Play(evt, source, PlaybackType.WORLDSPACE); source.transform.parent = player.transform; source.transform.localPosition = Vector3.zero; source.transform.localRotation = Quaternion.identity; return(playback); }
/// <summary> /// Plays the specified event once on the specified player gameobject. /// This will make the playback audio source be parented to player at origin position and identity rotation. /// /// Note that this method is not doing any spatial playback configuration on the audio source _at all_. /// The audio event should do the spatial setup. /// /// Playback is done with an audio source which has the <see cref="ProximityBasedAudio"/> component. /// </summary> /// <param name="evt">The event to play</param> /// <param name="player">The object which is playing the event.</param> public Playback PlayProximity(AudioEvent evt, GameObject player) { var source = this.proximityAudioSources.Get(); source.gameObject.SetActive(true); Playback playback = Play(evt, source, PlaybackType.PROXIMITY); source.transform.parent = player.transform; source.transform.localPosition = Vector3.zero; source.transform.localRotation = Quaternion.identity; return(playback); }
/// <summary> /// Generic implementation for playing a specific event. /// /// <see cref="PlayNonSpatial(AudioEvent)"/> /// <see cref="PlayProximity(AudioEvent, GameObject)"/> /// <see cref="PlayWorldspace(AudioEvent, GameObject)"/> /// </summary> /// <typeparam name="T">The audio source type.</typeparam> /// <param name="evt">The event to play</param> /// <param name="source">The source on where to play it.</param> /// <returns>The created playback of the event.</returns> private Playback Play <T>(AudioEvent evt, T source, PlaybackType type) where T : IUTKAudioSource { evt.Play(source); var playback = new Playback() { evt = evt, source = source, type = type }; this.playbacks.Add(playback); return(playback); }