using System.Collections; using System.Collections.Generic; using UnityEngine; public class VAUSignalSourceAudioFile : VAUSignalSource { [Tooltip("Absolute or relative file path (relative to Assets folder or any folder added to search path using AddSearchPath)")] public string FilePath; public string Name; // Versatile name [Tooltip("Will loop the audio signal source.")] public bool IsLooping = true; [Tooltip("Will immediately start the signal source payback.")] public bool PlayOnStart = true; void Awake() { if (!VAUAdapter.VA.IsConnected()) return; _ID = VAUAdapter.VA.CreateSignalSourceBufferFromFile(FilePath, Name); Debug.Assert(_ID.Length > 0, "Could not create audio file signal source '" + Name + "' file from path " + FilePath); } void Start() { VAUAdapter.VA.SetSignalSourceBufferLooping(_ID, IsLooping); if (PlayOnStart) VAUAdapter.VA.SetSignalSourceBufferPlaybackAction(_ID, "PLAY"); } void OnDestroy() { if (_ID.Length > 0) VAUAdapter.VA.DeleteSignalSource(_ID); } }