public void Stop() { if (source == null) { return; } source.Stop(); source = null; }
public void Play(CPos position, bool loops, bool overwrite = true) { var vector = convert(position); dist = vector.Dist; if (source != null) { if (overwrite) { Stop(); } else { return; } } source = AudioController.Play(info.Buffer, inGame, defaultVolume * distanceVolume(), defaultPitch, vector, loops); }
/// <summary> /// Initializes the audio manager /// </summary> /// <param name="soundSource">audio source</param> public static void Initialize(GameAudioSource source) { initialized = true; gameAudioSource = source; // Load resources, using filenames in AudioClipNames enum foreach (AudioClipName clip in AudioClipName.GetValues(typeof(AudioClipName))) { if (!clip.ToString().StartsWith("Music_")) { soundClips.Add(clip, Resources.Load <AudioClip>(@"Audio\Sound\" + clip.ToString())); //Debug.Log("Loaded: " + clip.ToString()); } else { // Most music clips include a starter (intro) clip and a looped clip musicStartClips.Add(clip, Resources.Load <AudioClip>(@"Audio\Music\" + clip.ToString() + "_start")); //Debug.Log("Loaded: " + clip.ToString() + "_start"); musicLoopClips.Add(clip, Resources.Load <AudioClip>(@"Audio\Music\" + clip.ToString() + "_loop")); //Debug.Log("Loaded: " + clip.ToString() + "_loop"); } } // Load Player Volume Preferences if (PlayerPrefs.HasKey(PlayerPrefsKeys.SoundVolume.ToString())) { soundVolume = PlayerPrefs.GetFloat(PlayerPrefsKeys.SoundVolume.ToString()); } if (PlayerPrefs.HasKey(PlayerPrefsKeys.MusicVolume.ToString())) { musicVolume = PlayerPrefs.GetFloat(PlayerPrefsKeys.MusicVolume.ToString()); } gameAudioSource.SetSoundVolume(soundVolume); gameAudioSource.SetMusicVolume(musicVolume); }
/// <inheritdoc /> protected MonoAudioInstance([NotNull] GameAudioSource source) : base(source) { }
protected GameAudioInstance(GameAudioSource source) { Source = source; }
/// <inheritdoc /> protected MonoAudioInstance(GameAudioSource source) : base(source) { }