// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using System; using UnityEngine; namespace UltimateXR.Audio { /// /// Describes an audio clip that can be played and its parameters. /// [Serializable] public class UxrAudioSample { #region Inspector Properties/Serialized Fields [SerializeField] private AudioClip _clip; [SerializeField] [Range(0, 1)] private float _volume = 1.0f; #endregion #region Public Types & Data /// /// Gets or sets the audio clip. /// public AudioClip Clip { get => _clip; set => _clip = value; } /// /// Gets or sets the volume used when playing the clip. /// public float Volume { get => _volume; set => _volume = value; } #endregion #region Constructors & Finalizer /// /// Default constructor. /// public UxrAudioSample() { Clip = null; Volume = 1.0f; } #endregion #region Public Methods /// /// Plays the audio in a given position in space. /// /// World space coordinates where the audio will be played. public void Play(Vector3 position) { if (Clip != null) { AudioSource.PlayClipAtPoint(Clip, position, Volume); } } #endregion } }