public bool PlayRandom(AudioAssetGroup audioAssetGroup, bool loop = false) { List <AudioAsset> audioAssets = new List <AudioAsset>(audioAssetGroup.AudioAssets); AudioAsset target = audioAssets[Random.Range(0, audioAssets.Count)]; return(Play(audioAssetGroup, target, loop)); }
public void FadeOut(float steps) { if (activeAudioAssetGroup != null && channel != null) { audioManager.FadeOut(channel, steps); activeAudioAssetGroup = null; } }
public void FadeOut(float steps) { if (activeAudioAssetGroup != null && channel != null) { audioManager.FadeOut(channel , steps); activeAudioAssetGroup = null; } }
private static void CreateAudioAssets() { if (Selection.objects.Length > 0) { List <AudioAsset> targets = new List <AudioAsset>(); foreach (Object obj in Selection.objects) { if (obj.GetType() == typeof(AudioAsset)) { targets.Add(obj as AudioAsset); } } if (targets.Count > 0) { string path = AssetDatabase.GetAssetPath(targets[0]); if (!string.IsNullOrEmpty(path)) { int lastIndex = path.LastIndexOf(Path.DirectorySeparatorChar); if (lastIndex <= 0) { lastIndex = path.LastIndexOf(Path.AltDirectorySeparatorChar); } if (lastIndex > 0) { path = path.Substring(0, lastIndex + 1); path += "AudioAssetGroup.asset"; } else { path = EditorUtility.SaveFilePanelInProject("Create AudioAssetGroup", "AudioAssetGroup", "asset", "Create a nw AudioAssetGroup."); if (string.IsNullOrEmpty(path)) { return; } } AudioAssetGroup asset = CreateInstance <AudioAssetGroup>(); asset.audioAssets = new AudioAsset[targets.Count]; targets.CopyTo(asset.audioAssets); AssetDatabase.CreateAsset(asset, path); AssetDatabase.SaveAssets(); Selection.activeObject = asset; } } } }
public void Play(AudioAssetGroup audioAssetGroup, bool loop = false) { if (activeAudioAssetGroup != audioAssetGroup) { activeAudioAssetGroup = audioAssetGroup; if (activeAudioAssetGroup != null) { channel.Stop(); channel.PlayRandom(activeAudioAssetGroup, loop); } } }
public void Play(AudioAssetGroup audioAssetGroup , bool loop = false) { if (activeAudioAssetGroup != audioAssetGroup) { activeAudioAssetGroup = audioAssetGroup; if (activeAudioAssetGroup != null) { channel.Stop(); channel.PlayRandom(activeAudioAssetGroup , loop); } } }
public AudioChannel PlayRandom(AudioAssetGroup audioAssetGroup , bool loop = false) { if (audioAssetGroup == null) { return null; } foreach (AudioChannel channel in channels) { if (claimedChannels.Contains(channel)) { continue; } if (channel.PlayRandom(audioAssetGroup , loop)) { return channel; } } Debug.LogWarning("[AudioManager] No available audio channels for audio asset group: " + audioAssetGroup); return null; }
public AudioChannel PlayRandom(AudioAssetGroup audioAssetGroup, bool loop = false) { if (audioAssetGroup == null) { return(null); } foreach (AudioChannel channel in channels) { if (claimedChannels.Contains(channel)) { continue; } if (channel.PlayRandom(audioAssetGroup, loop)) { return(channel); } } Debug.LogWarning("[AudioManager] No available audio channels for audio asset group: " + audioAssetGroup); return(null); }
public bool Play(AudioAssetGroup audioAssetGroup, AudioAsset audioAsset, bool loop = false) { return(Play(audioAsset, loop, audioAssetGroup.AudioMixerGroup ?? audioAsset.AudioMixerGroup)); }
public bool PlayRandom(AudioAssetGroup audioAssetGroup , bool loop = false) { List<AudioAsset> audioAssets = new List<AudioAsset>(audioAssetGroup.AudioAssets); AudioAsset target = audioAssets[Random.Range(0 , audioAssets.Count)]; return Play(audioAssetGroup , target , loop); }
public bool Play(AudioAssetGroup audioAssetGroup , AudioAsset audioAsset , bool loop = false) { return Play(audioAsset , loop , audioAssetGroup.AudioMixerGroup ?? audioAsset.AudioMixerGroup); }