internal AudioSource GetAudioSource(string label) { SoundAudioPlayer player = GetPlayer(label); if (player == null) { return(null); } return(player.Audio.AudioSource); }
internal float GetSamplesVolume(string label) { SoundAudioPlayer player = GetPlayer(label); if (player == null) { return(0); } return(player.GetSamplesVolume()); }
internal void Stop(string label, float fadeTime) { SoundAudioPlayer player = GetPlayer(label); if (player == null) { return; } player.Stop(fadeTime); }
internal bool IsPlayingLoop(string label) { SoundAudioPlayer player = GetPlayer(label); if (player == null) { return(false); } return(player.IsPlayingLoop()); }
SoundAudioPlayer GetPlayerOrCreateIfMissing(string label) { SoundAudioPlayer player = GetPlayer(label); if (player == null) { player = this.transform.AddChildGameObjectComponent <SoundAudioPlayer>(label); player.Init(label, this); PlayerList.Add(label, player); } return(player); }
SoundAudioPlayer GetOnlyOnePlayer(string label, float fadeOutTime) { SoundAudioPlayer player = GetPlayerOrCreateIfMissing(label); if (PlayerList.Count > 1) { foreach (var keyValue in PlayerList) { if (keyValue.Value != player) { keyValue.Value.Stop(fadeOutTime); } } } return(player); }
//初期化 public void Init(SoundAudioPlayer player, SoundData soundData) { this.Player = player; this.Data = soundData; this.Audio0 = this.gameObject.AddComponent <AudioSource>(); Audio0.playOnAwake = false; if (Data.EnableIntroLoop) { Audio1 = this.gameObject.AddComponent <AudioSource>(); Audio1.playOnAwake = false; Audio1.clip = Data.Clip; Audio1.loop = false; } AudioSource = Audio0; AudioSource.clip = Data.Clip; AudioSource.loop = Data.IsLoop && !Data.EnableIntroLoop; if (Data.File != null) { Data.File.AddReferenceComponent(this.gameObject); } }
//セーブデータ用のバイナリ読み込み internal void Read(BinaryReader reader) { int version = reader.ReadInt32(); if (version <= Version) { if (version > Version0) { GroupVolume = reader.ReadSingle(); } int playerCount = reader.ReadInt32(); for (int i = 0; i < playerCount; ++i) { string label = reader.ReadString(); SoundAudioPlayer player = GetPlayerOrCreateIfMissing(label); reader.ReadBuffer(player.Read); } } else { Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.UnknownVersion, version)); } }
internal void Play(string label, SoundData data, float fadeInTime, float fadeOutTime) { SoundAudioPlayer player = (MultiPlay) ? GetPlayerOrCreateIfMissing(label) : GetOnlyOnePlayer(label, fadeOutTime); player.Play(data, fadeInTime, fadeOutTime); }