public void ChangeModel(string modelName) { int layer = model.layer; if (isPutPool) { GameObjectManager.DestroyGameObjectByPool(model); } else { UnityEngine.Object.Destroy(model); } model = GameObjectManager.CreateGameObjectByPool(modelName); model.transform.SetParent(root.transform); model.transform.localPosition = new Vector3(0, 0, 0); model.transform.localEulerAngles = Vector3.zero; model.transform.localScale = Vector3.one; model.SetLayer(layer); }
/// <summary> /// 删除所有隐藏的UI /// </summary> public static void DestroyAllHideUI() { foreach (List <UIWindowBase> uis in s_hideUIs.Values) { for (int i = 0; i < uis.Count; i++) { UISystemEvent.Dispatch(uis[i], UIEvent.OnDestroy); //派发OnDestroy事件 try { uis[i].Dispose(); } catch (Exception e) { Debug.LogError("OnDestroy :" + e.ToString()); } GameObjectManager.DestroyGameObjectByPool(uis[i].gameObject); } } s_hideUIs.Clear(); }
public void SetPos(Vector3 pos) { //清空已有资源 for (int i = 0; i < m_rendererList.Count; i++) { GameObjectManager.DestroyGameObjectByPool(m_rendererList[i].gameObject); } m_rendererList.Clear(); //计算出应该是哪几个资源 //计算出对应的位置 //加载并摆放 m_offset = pos * scrollSpeed; //限制区域 int index = 0; bool isBreak = false; bool isShow = false; while (!isBreak) { GroundInfo info = GetGroundInfo(index); if (m_root.ViewBound.Overlaps(info.rect)) { isShow = true; //加载对应资源并摆放 CreateSprite(info); } else { //已经显示过,后面的不在显示区域中终止循环 if (isShow) { isBreak = true; } } index++; } }
public static void DestroyUI(UIWindowBase UI) { Debug.Log("UIManager DestroyUI " + UI.name); if (GetIsExitsHide(UI)) { RemoveHideUI(UI); } else if (GetIsExits(UI)) { RemoveUI(UI); } UISystemEvent.Dispatch(UI, UIEvent.OnDestroy); //派发OnDestroy事件 try { UI.Dispose(); } catch (Exception e) { Debug.LogError("OnDestroy :" + e.ToString()); } GameObjectManager.DestroyGameObjectByPool(UI.gameObject); }
public void Dispose() { GameObjectManager.DestroyGameObjectByPool(model); GameObject.Destroy(top); }
private void LoadQueue() { if (currentNum >= count) { RunCallBack(); Destroy(); return; } PreloadResourcesDataGenerate da = queueRes[currentNum]; currentNum++; //Debug.Log("da.m_key " + da.m_key); try { string typeStr = da.m_ResType.ToString().Replace("_", "."); Type resType = ReflectionUtils.GetTypeByTypeFullName(typeStr); // object loadRes = AssetsPoolManager.Load(da.m_key); AssetsPoolManager.LoadAsync(da.m_key, resType, (LoadState loadState, object loadRes) => { if (loadState.isDone) { if (loadRes != null) { if (loadRes is GameObject) { GameObject prefab = (GameObject)loadRes; List <GameObject> resList = new List <GameObject>(); for (int i = 0; i < da.m_instantiateNum; i++) { GameObject obj = GameObjectManager.CreateGameObjectByPool(prefab); resList.Add(obj); } foreach (var obj in resList) { GameObjectManager.DestroyGameObjectByPool(obj, !da.m_createInstanceActive); } } else { AssetsPoolManager.DestroyByPool(da.m_key); } } else { if (loadRes == null) { Debug.LogError("Error: 预加载失败 key:" + da.m_key); } } RunCallBack(); LoadQueue(); } }); } catch (Exception e) { Debug.LogError(e); LoadQueue(); } }