private void LoadAudioClipPath(string path, int type, float volume, Vector3 position, float delay, float time = 0, int priority = 128, bool loop = false, float minPitch = 0, float maxPitch = 3, float maxDistance = 25, float spatialBlend = 0) { if (string.IsNullOrEmpty(path)) { return; } if (sounds[path] != null) { var audioData = sounds[path] as AudioData; if (audioData != null && audioData.audio != null) { audioData.audio.volume = _closeSound ? 0f : volume; audioData.go.transform.position = position; audioData.Play(delay); } else { sounds.RemoveKey(path); } } else { var data = new AudioData(path, (SoundType)type, loop, SoundParent.transform, position, priority, minPitch, maxPitch, volume, maxDistance, spatialBlend); string extension = Path.GetExtension(path); string fileName = path.Replace(extension, ""); extension = extension.Substring(1); ResourceManager.LoadAudioClipBundleAsync(fileName, extension) .Then((audioClip) => { if (audioClip == null) { throw new Exception(string.Format("Cant Load AudioClip! Path :{0}", path)); } if (data.audio != null) { data.audio.clip = audioClip; data.audio.volume = _closeSound ? 0f : volume; data.audio.time = time; data.Play(delay); sounds.Put(path, data); } }) .Catch(e => Debug.LogException(e)); } }
private void OnReleasePanelData(PanelData data) { uiList.RemoveKey(data.Name); if (data.PanelObject != null) { Destroy(data.PanelObject); } }
/// <summary> /// 添加元素 /// </summary> /// <param name="key"></param> /// <param name="value"></param> public void Put(K key, V value) { //先从LRU缓存中进行命中测试 Node <K, V> node = ruCache.GetNode(key); if (node != null) { //lru缓存链中被命中,则添加到LFU中 ruCache.RemoveKey(key); fuCache.Put(key, value); return; } //从LFU中进行命中测试 node = fuCache.GetNode(key); if (node != null) { return; } //检测幽灵命中,已经被释放的资源重新添加 int maxCapactity = initCapactity + initCapactity / 2; node = ruGhostCache.GetNode(key); if (node != null) { if (ruCache.Full && ruCache.Capactity < maxCapactity) { ruCache.Capactity++; fuCache.CapacityMax--; } ruCache.Put(key, value); ruGhostCache.RemoveKey(key); return; } node = fuGhostCache.GetNode(key); if (node != null) { if (fuCache.Full && fuCache.CapacityMax < maxCapactity) { fuCache.CapacityMax++; ruCache.Capactity--; } LFUCache <K, V> .LFUNode <K, V> fuNode = node as LFUCache <K, V> .LFUNode <K, V>; fuCache.Put(key, value, fuNode.RefCount); fuGhostCache.RemoveKey(key); return; } //新资源处理 ruCache.Put(key, value); }