public bool Play(AudioCollection collection, int bank, int layer, bool looping = true) { // Layer must be in range if (layer >= audioLayers.Count) { return(false); } // Fetch the layer to configure AudioLayer audioLayer = audioLayers[layer]; // Already doing what is intended if (audioLayer.collection == collection && audioLayer.looping == looping && bank == audioLayer.bank) { return(true); } audioLayer.collection = collection; audioLayer.bank = bank; audioLayer.looping = looping; audioLayer.time = 0.0f; audioLayer.duration = 0.0f; audioLayer.muted = false; audioLayer.clip = null; return(true); }
public virtual void MuteSfx() { if (_overrided) { return; } AudioCollection audioCollection = FindObjectOfType <AudioCollection>(); if (audioCollection == null) { return; } IsSfxMuted = PlayerPrefs.GetInt("IsMuted") != 1; PlayerPrefs.SetInt("IsMuted", IsSfxMuted ? 1 : 0); GameObject audioManager = audioCollection.gameObject; AudioSource[] components = audioManager.GetComponents <AudioSource>(); foreach (var item in audioCollection.audioCollection.Where(audio => audio.Name.StartsWith("sfx"))) { foreach (var sfx in components.Where(i => i.clip.name.Equals(item.AudioClip.name))) { sfx.mute = IsSfxMuted; } } OnMuteGameEvent?.Invoke("sfx"); }
// ------------------------------------------------------------------------ // Name : Play // Desc : // ------------------------------------------------------------------------ public bool Play(AudioCollection collection, int bank, int layer, bool looping = true) { /// Layer must be in range if (layer >= _audioLayers.Count) { return(false); } // Fetch the layer we wish to configure AudioLayer audioLayer = _audioLayers[layer]; // Already doing what we want then just return true if (audioLayer.Collection == collection && audioLayer.Looping == looping && bank == audioLayer.Bank) { return(true); } audioLayer.Collection = collection; audioLayer.Bank = bank; audioLayer.Looping = looping; audioLayer.Time = 0.0f; audioLayer.Duration = 0.0f; audioLayer.Muted = false; audioLayer.Clip = null; return(true); }
public override void OnEnter() { PlaySound(AudioCollection.Get("jump")); Animations.SetAnim("jump"); Movement.Jump(); base.OnEnter(); }
public bool Play(AudioCollection collection, int bank, int layer, bool looping = true) { // Layer must be in range if (layer >= _audioLayers.Count) { return(false); } AudioLayer audioLayer = _audioLayers[layer]; // If it's already doing what we want, then we just return if (audioLayer.Collection == collection && audioLayer.Bank == bank && audioLayer.Looping == looping) { return(true); } audioLayer.Collection = collection; audioLayer.Bank = bank; audioLayer.Looping = looping; audioLayer.Time = 0f; audioLayer.Duration = 0f; audioLayer.Muted = false; audioLayer.Clip = null; return(true); }
public bool PlayAudio(AudioCollection clipPool, int bank, int layer, bool looping = true) { if (_layeredAudioSource == null) { return(false); } return(_layeredAudioSource.Play(clipPool, bank, layer, looping)); }
private void AnimationsOnOnFrameEnter(int frameIndex, int frameValue) { if (frameIndex == 0) { PlaySound(AudioCollection.Get("step_left")); } if (frameIndex == 3) { PlaySound(AudioCollection.Get("step_right")); } }
private void Start() { _audioCollection = GetComponent <AudioCollection>(); InitSounds(); AttachButtonSfx(); // Reattach button sfx every scene change SceneManager.activeSceneChanged += OnSceneChanged; }
private void OnPlayAudio(string constString) { AudioCollection ac = collectionList.Find(x => x.name == constString); if (ac != null) { ac.play(); } else { Debug.LogError("AudioCollection not set for " + constString); } }
public override void OnInspectorGUI() { _collection = (AudioCollection)target; foreach (var bundle in _collection.Collection.ToArray()) { DrawBundle(bundle); } if (GUILayout.Button("+")) { AddBundle(); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); position.height = EditorGUIUtility.singleLineHeight; var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; EditorGUI.BeginChangeCheck(); property.FindPropertyRelative("_useCollection").boolValue = GUI.Toggle(new Rect(position) { width = _width }, property.FindPropertyRelative("_useCollection").boolValue, "Use Collection", "Button"); if (property.FindPropertyRelative("_useCollection").boolValue) { EditorGUI.PropertyField(new Rect(position.x + _width, position.y, position.width - _width, position.height), property.FindPropertyRelative("_collection"), GUIContent.none); AudioCollection collection = property.FindPropertyRelative("_collection").objectReferenceValue as AudioCollection; position.position = new Vector2(position.x, position.y + EditorGUIUtility.singleLineHeight); if (collection != null) { var list = new string[collection.Collection.Count]; for (var i = 0; i < collection.Collection.Count; ++i) { list[i] = collection.Collection[i].Key; } property.FindPropertyRelative("_selected").intValue = EditorGUI.Popup(position, property.FindPropertyRelative("_selected").intValue, list); } } else { EditorGUI.PropertyField(new Rect(position.x + _width, position.y, position.width - _width, position.height), property.FindPropertyRelative("_singleClip"), GUIContent.none, false); } // Set indent back to what it was EditorGUI.indentLevel = indent; EditorGUI.EndProperty(); }
public void LoadDefault() { DirectoryInfo artDir = new DirectoryInfo(System.IO.Path.Combine(Locations.ArtemisCopyPath, "dat")); try { foreach (FileInfo f in artDir.GetFiles("*.ogg")) { if (!f.Name.StartsWith("silence", StringComparison.OrdinalIgnoreCase)) { AudioCollection.Add(f.FullName); SetAudioList(); } } } catch { } }
// One-shot functions (Non-diagetic) public void PlayRandomUIAudio(AudioCollection clipCollection) { if (clipCollection == null) { return; } // Try to get a random clip. If unsuccessful, AudioClip randomClip = clipCollection.GetRandomClip(); if (randomClip != null) { // 1. Create new Audio object GameObject oneShotObject = new GameObject(randomClip.name); oneShotObject.transform.parent = oneShotClips.transform; CreateAudioSource(randomClip, oneShotObject, this.transform.position, clipCollection.Volume, clipCollection.PitchVariance, false, false); Destroy(oneShotObject, randomClip.length); } }
public async Task <IList <AudioCollection> > GetAlbums(String userId = null, String groupId = null) { IList <AudioCollection> audioCollections; if (ViewModelLocator.AuthService.IsLoggedInVk(true)) { VkAudioRequest audio = this._vkontakte.Audio; String str = userId; String str1 = str; if (str == null) { str1 = this._vkontakte.AccessToken.UserId; } IEnumerable <VkAudioAlbum> albums = await audio.GetAlbums(str1, groupId, 0, 0); IEnumerable <VkAudioAlbum> vkAudioAlbums = albums; if (vkAudioAlbums == null) { audioCollections = null; } else { IEnumerable <VkAudioAlbum> vkAudioAlbums1 = vkAudioAlbums; List <AudioCollection> list = vkAudioAlbums1.Select <VkAudioAlbum, AudioCollection>((VkAudioAlbum a) => { AudioCollection audioCollection = new AudioCollection(); Double id = a.Id; audioCollection.Id = id.ToString(CultureInfo.InvariantCulture); audioCollection.Title = a.Title; Double ownerId = a.OwnerId; audioCollection.OwnerId = ownerId.ToString(CultureInfo.InvariantCulture); return(audioCollection); }).ToList <AudioCollection>(); audioCollections = list; } } else { audioCollections = null; } return(audioCollections); }
// Plays a continuous random audio clip parented to a given source. // Multiple Audio Clips can play simultaneously. public GameObject PlayRandomContinuousAudio(AudioCollection clipCollection, Transform source, float maxDuration = 10f) { if (clipCollection == null) { return(null); } // Try to get a random clip. If unsuccessful, AudioClip randomClip = clipCollection.GetRandomClip(); GameObject continuousObject = null; if (randomClip != null) { // 1. Create new Audio object continuousObject = new GameObject(randomClip.name); continuousObject.transform.parent = source.transform; Vector3 positionOffset = cameraLocationOffset; CreateAudioSource(randomClip, continuousObject, source.position - new Vector3(positionOffset.x, 0, positionOffset.z), clipCollection.Volume, clipCollection.PitchVariance, true); Destroy(continuousObject, maxDuration); } return(continuousObject); }
public AudioClip GetRandomClip(AudioCollection col) { int rand = Mathf.RoundToInt(Random.Range(0f, (float)col.audioClips.Count - 1)); return(col.audioClips[rand]); }
public void SetAudioList() { IsUpdating = true; AudioList = string.Join(";", AudioCollection.ToArray <string>()); IsUpdating = false; }
private void OnEnable() { customCollection = (AudioCollection)target; sPAudioCollections = serializedObject.FindProperty("audioCollection"); }
public AudioService(AudioCollection audioCollection) { _poolService = ServiceLocator.GetService <PoolService>(); _audioCollection = audioCollection; }