internal bool RecycleObject(Object obj) { bool ret = false; if (null != obj) { //GameObject gameObject = obj as GameObject; //if (null != gameObject) { //LogicSystem.LogFromGfx("RecycleObject {0} {1}", gameObject.name, gameObject.tag); //} int objId = obj.GetInstanceID(); if (m_UsedResources.Contains(objId)) { UsedResourceInfo resInfo = m_UsedResources[objId]; if (null != resInfo) { FinalizeObject(resInfo.m_Object); RemoveFromUsedResources(objId); AddToUnusedResources(resInfo.m_ResId, obj); resInfo.Recycle(); ret = true; } } } return(ret); }
internal void CleanupResourcePool() { CleanUseResource(); for (LinkedListNode <UsedResourceInfo> node = m_UsedResources.FirstValue; null != node;) { UsedResourceInfo resInfo = node.Value; node = node.Next; RemoveFromUsedResources(resInfo.m_ObjId); resInfo.Recycle(); } foreach (KeyValuePair <int, Queue <UnityEngine.Object> > pair in m_UnusedResources) { int key = pair.Key; Queue <UnityEngine.Object> queue = pair.Value; queue.Clear(); } foreach (KeyValuePair <string, ObjectEx> pair in m_LoadedPrefabs) { string key = pair.Key; if (pair.Value.notdesotryed) { continue; } m_WaitDeleteLoadedPrefabEntrys.Add(key); } for (int i = 0; i < m_WaitDeleteLoadedPrefabEntrys.Count; i++) { m_LoadedPrefabs.Remove(m_WaitDeleteLoadedPrefabEntrys[i]); } m_WaitDeleteLoadedPrefabEntrys.Clear(); UnityEngine.Resources.UnloadUnusedAssets(); }
public void Tick() { float curTime = Time.time; for (LinkedListNode <UsedResourceInfo> node = m_UsedResources.FirstValue; null != node;) { UsedResourceInfo resInfo = node.Value; if (resInfo.m_RecycleTime > 0 && resInfo.m_RecycleTime < curTime) { node = node.Next; UnityEngine.GameObject gameObject = resInfo.m_Object as UnityEngine.GameObject; if (null != gameObject) { } FinalizeObject(resInfo.m_Object); AddToUnusedResources(resInfo.m_ResId, resInfo.m_Object); RemoveFromUsedResources(resInfo.m_ObjId); resInfo.Recycle(); } else { node = node.Next; } } }
public bool RecycleObject(UnityEngine.Object obj) { bool ret = false; if (null != obj) { UnityEngine.GameObject gameObject = obj as UnityEngine.GameObject; if (null != gameObject) { } int objId = obj.GetInstanceID(); if (m_UsedResources.Contains(objId)) { UsedResourceInfo resInfo = m_UsedResources[objId]; if (null != resInfo) { FinalizeObject(resInfo.m_Object); RemoveFromUsedResources(objId); AddToUnusedResources(resInfo.m_ResId, obj); resInfo.Recycle(); ret = true; } } } return(ret); }
public void Tick() { float curTime = Time.time; /* * if (m_LastTickTime <= 0) { * m_LastTickTime = curTime; * return; * } * float delta = curTime - m_LastTickTime; * if (delta < 0.1f) { * return; * } * m_LastTickTime = curTime; */ for (LinkedListNode <UsedResourceInfo> node = m_UsedResources.FirstValue; null != node;) { UsedResourceInfo resInfo = node.Value; if (resInfo.m_RecycleTime > 0 && resInfo.m_RecycleTime < curTime) { node = node.Next; UnityEngine.GameObject gameObject = resInfo.m_Object as UnityEngine.GameObject; if (null != gameObject) { //BridgeForGfxModule.BgLog("RecycleObject {0} {1} by Tick", gameObject.name, gameObject.tag); } FinalizeObject(resInfo.m_Object); AddToUnusedResources(resInfo.m_ResId, resInfo.m_Object); RemoveFromUsedResources(resInfo.m_ObjId); resInfo.Recycle(); } else { node = node.Next; } } }
internal void Tick() { float curTime = Time.time; /* * if (m_LastTickTime <= 0) { * m_LastTickTime = curTime; * return; * } * float delta = curTime - m_LastTickTime; * if (delta < 0.1f) { * return; * } * m_LastTickTime = curTime; */ for (LinkedListNode <UsedResourceInfo> node = m_UsedResources.FirstValue; null != node;) { UsedResourceInfo resInfo = node.Value; if (resInfo.m_RecycleTime > 0 && resInfo.m_RecycleTime < curTime) { node = node.Next; //GameObject gameObject = resInfo.m_Object as GameObject; //if (null != gameObject) { //LogicSystem.LogFromGfx("RecycleObject {0} {1} by Tick", gameObject.name, gameObject.tag); //} FinalizeObject(resInfo.m_Object); AddToUnusedResources(resInfo.m_ResId, resInfo.m_Object); RemoveFromUsedResources(resInfo.m_ObjId); resInfo.Recycle(); } else { node = node.Next; } } }
public void CleanupResourcePool() { for (LinkedListNode <UsedResourceInfo> node = m_UsedResources.FirstNode; null != node;) { UsedResourceInfo resInfo = node.Value; node = node.Next; RemoveFromUsedResources(resInfo.m_ObjId, -1); resInfo.Recycle(); } for (int i = 0; i < m_GroupedResources.Count; ++i) { m_GroupedResources[i].Resources.Clear(); } foreach (var pair in m_UnusedResources) { int key = pair.Key; var heap = pair.Value; heap.Clear(); } foreach (KeyValuePair <string, ObjectEx> pair in m_LoadedPrefabs) { string key = pair.Key; if (pair.Value != null && pair.Value.DontDestroyed) { continue; } m_WaitDeleteLoadedPrefabEntrys.Add(key); } for (int i = 0; i < m_WaitDeleteLoadedPrefabEntrys.Count; i++) { m_LoadedPrefabs.Remove(m_WaitDeleteLoadedPrefabEntrys[i]); } m_WaitDeleteLoadedPrefabEntrys.Clear(); Resources.UnloadUnusedAssets(); }
internal bool RecycleObject(UnityEngine.Object obj) { bool ret = false; if (null != obj) { int objId = obj.GetInstanceID(); if (m_UsedResources.Contains(objId)) { UsedResourceInfo resInfo = m_UsedResources[objId]; if (null != resInfo) { FinalizeObject(resInfo.m_Object); RemoveFromUsedResources(objId); AddToUnusedResources(resInfo.m_ResId, obj); resInfo.Recycle(); ObjectCache.Instance.Push <UsedResourceInfo>(resInfo); ret = true; } } } return(ret); }
public void Tick() { float curTime = Time.time; for (LinkedListNode <UsedResourceInfo> node = m_UsedResources.FirstNode; null != node;) { UsedResourceInfo resInfo = node.Value; if (resInfo.m_RecycleTime > 0 && resInfo.m_RecycleTime < curTime) { node = node.Next; UnityEngine.GameObject gameObject = resInfo.m_Object as UnityEngine.GameObject; if (null != gameObject) { } FinalizeObject(resInfo.m_Object); AddToUnusedResources(resInfo.m_ResId, resInfo.m_Object); RemoveFromUsedResources(resInfo.m_ObjId, resInfo.m_Group); resInfo.Recycle(); } else { node = node.Next; } } if (m_LastUnusedCheckTime + c_UnusedCheckInterval < curTime) { m_LastUnusedCheckTime = c_UnusedCheckInterval; bool fullCheck = m_ResPoolRootTransform.childCount >= m_MaxUnusedObjectNum; int ct = 0; foreach (var pair in m_UnusedResources) { var heap = pair.Value; if (heap.Count >= m_MaxSameUnusedObjectNum || fullCheck) { try { var tree = heap.LockData(); for (int i = tree.Count - 1; i >= 0; --i) { var info = tree[i]; if (info.UnuseTime + m_MaxUnuseTimeForCleanup <= curTime) { ++ct; heap.SetDataDirty(); tree.RemoveAt(i); GameObject go = info.Obj as GameObject; if (null != go) { go.transform.SetParent(null); } GameObject.Destroy(info.Obj); info.Recycle(); } } } finally { heap.UnlockData(); } } if (ct > 10) { break; } } } }
internal void CleanupResourcePool() { for (LinkedListNode <UsedResourceInfo> node = m_UsedResources.FirstValue; null != node;) { UsedResourceInfo resInfo = node.Value; if (!m_PreloadResources.Contains(resInfo.m_ResId)) { node = node.Next; RemoveFromUsedResources(resInfo.m_ObjId); resInfo.Recycle(); } else { node = node.Next; } } foreach (KeyValuePair <int, Queue <Object> > pair in m_UnusedResources) { int key = pair.Key; if (m_PreloadResources.Contains(key)) { continue; } Queue <Object> queue = pair.Value; queue.Clear(); } foreach (KeyValuePair <string, Object> pair in m_LoadedPrefabs) { string key = pair.Key; Object obj = pair.Value; if (null != obj) { try { int instId = obj.GetInstanceID(); if (!m_PreloadResources.Contains(instId)) { m_WaitDeleteLoadedPrefabEntrys.Add(key); } } catch (System.Exception ex) { m_WaitDeleteLoadedPrefabEntrys.Add(key); LogicSystem.LogErrorFromLogic("Exception:{0} stack:{1}", ex.Message, ex.StackTrace); } } else { m_WaitDeleteLoadedPrefabEntrys.Add(key); } } for (int i = 0; i < m_WaitDeleteLoadedPrefabEntrys.Count; i++) { m_LoadedPrefabs.Remove(m_WaitDeleteLoadedPrefabEntrys[i]); } /* * foreach (string key in m_WaitDeleteLoadedPrefabEntrys) { * m_LoadedPrefabs.Remove(key); * }*/ m_WaitDeleteLoadedPrefabEntrys.Clear(); Resources.UnloadUnusedAssets(); }