public AudioController(IAudioClipProvider clipProvider) { var gameObject = new GameObject("_AudioController"); _audioSource = gameObject.AddComponent <AudioSource>(); GameObject.DontDestroyOnLoad(gameObject); _clipProvider = clipProvider; }
/// <summary> /// Constructor. /// </summary> /// <param name="sfxType">A keyword or phase associated with this audio player.</param> /// <param name="clipProvider">The clip provider to use.</param> /// <param name="audio">The audio source to use each time a clip is played.</param> public SfxAudioPlayer(string sfxType, IAudioClipProvider clipProvider, IAudio audio) { SfxType = sfxType; this.clipProvider = clipProvider; this.currentAudio = audio; }
/// <summary> /// Constructor. /// </summary> /// <param name="sfxType">A keyword or phase associated with this audio player.</param> /// <param name="clipProvider">The clip provider to use.</param> /// <param name="audioFactory">The audio source factory to use each time a clip is played.</param> public SfxAudioPlayer(string sfxType, IAudioClipProvider clipProvider, IAudioFactory audioFactory) { SfxType = sfxType; this.clipProvider = clipProvider; this.audioFactory = audioFactory; }
/// <summary> /// Create a SFX audio player and associate it with the sfxType keyword. /// </summary> /// <param name="sfxType">A keyword or phrase used to request this player.</param> /// <param name="audioType">A string reference to an existing audio source factory.</param> /// <param name="clipProvider">A instance of IAudioClipProvider that determines which clip to play.</param> /// <returns>An audio player. Can be used to bypass the AUdioManagerSingleton or ignored.</returns> public ISfxAudioPlayer CreateSfxAudioPlayer(string sfxType, string audioType, IAudioClipProvider clipProvider) { ISfxAudioPlayer sfxAudioPlayer = new SfxAudioPlayerUsingAudioFactoryRegistry(sfxType, clipProvider, audioType); AudioManagerSingleton.Instance.RegisterAudioPlayer(sfxAudioPlayer); return(sfxAudioPlayer); }
/// <summary> /// Constructor. /// </summary> /// <param name="sfxType">A keyword or phase associated with this audio player.</param> /// <param name="clipProvider">The clip provider to use.</param> /// <param name="audioType">The name of the registered audio source factory.</param> public SfxAudioPlayerUsingAudioFactoryRegistry(string sfxType, IAudioClipProvider clipProvider, string audioType) : base(sfxType, clipProvider, AudioFactoryRegistry.Instance.GetAudioFactory(audioType)) { }