private void _addAsbInfo(string asbName, string name, string extral, bool isOrdered) { if (null == OnLoadCallbcak) { return; } AsbInfo info = ObjPools.GetAsbInfo(); info.Set(asbName, name, extral); if (isOrdered) { if (!mQueue.Contains(info)) { mQueue.Enqueue(info); return; } } else { if (!mList.Contains(info)) { mList.Add(info); return; } } //如果已经在list或者队列里则回收 ObjPools.Recover(info); return; }
protected override void OnDestroy() { recoverAll(); if (null != mCurItems) { mCurItems.Clear(); } if (null != mItemPool) { mItemPool.Dispose(); } if (null != mItemDatas) { for (int i = 0; i < mItemDatas.Count; i++) { mItemDatas[i].Dispose(); } mItemDatas.Clear(); } if (null != mOnItemClickLua) { mOnItemClickLua.Dispose(); mOnItemClickLua = null; } if (null != mItemSelectStatus) { ObjPools.Recover(mItemSelectStatus); } if (null != mOnSelectChangeLua) { mOnSelectChangeLua.Dispose(); mOnSelectChangeLua = null; } base.OnDestroy(); }
/// <summary> /// 从prefab显示UI,慎用,建议使用ShowView /// </summary> /// <param name="prefab">Prefab.</param> /// <param name="luaTable">Lua table.</param> /// <param name="asbName">Asb name.</param> /// <param name="prefabName">Prefab name.</param> public void ShowViewPrefab(GameObject prefab, LuaTable luaTable = null, string asbName = null, string prefabName = null) { if (null != prefab) { GameObject uiObj = Instantiate(prefab); UIBase ui = uiObj.GetComponent <UIBase>(); if (null != luaTable) { ui.SetLuaStatusListeners(luaTable); } _addUIObj(ui); if (ui.IsStatic) { if (mStaticViewInfos.Count == mStaticViews.Count) { AsbInfo info = ObjPools.GetAsbInfo(); info.Set(asbName, prefabName); mStaticViewInfos.Add(info); mStaticViews.Add(ui); } else { LogFile.Error("GameUIManager error ==> showViewPrefab mStaticViewInfos.Count != mStaticViews.Count"); } } //要显示UI先SetActive(true),防止有UIprefab中没有启用,不会进入Start方法 uiObj.SetActive(true); //UI初始化后才Show(播放显示动画) ui.OnInitCallbcak = (bool hasInit) => { if (ui.IsInStack) { if (ui.HideBefor && mStackViews.Count > 0) { UIBase curView = mStackViews.Peek(); if (curView.isActiveAndEnabled) { HideView(curView, (bool ret) => { _pushUI(ui as UIView); ShowViewObj(ui, null); }); return; } } //之前的UI隐藏或者本UI被设置为不隐藏之前的UI则不隐藏之前的UI直接push { _pushUI(ui as UIView); ShowViewObj(ui, null); } } else { ShowViewObj(ui, null); } }; } }
protected override void Awake() { base.Awake(); mItemPool = new ObjPool <ScrollItem>(onPoolGetDelegate, onPoolRecoverDelegate, onPoolDisposeDelegate); mCurItems = new List <ScrollItem>(); mItemSelectStatus = ObjPools.GetListBool(); //// 开启回弹 //movementType = MovementType.Elastic; //elasticity = 0.05f; //// 关闭移动结束后回弹惯性 //inertia = false; }
private bool _onLoad(string asbName, string assetName, T t) { bool ret = mDict.AddObj(asbName, assetName, t); if (null != OnLoadCallbcak) { if (mList.Count > 0) { for (int i = mList.Count - 1; i > -1; --i) { AsbInfo info = mList[i]; if (info.Equals(asbName, assetName)) { OnLoadCallbcak(t, info); mList.Remove(info); ObjPools.Recover(info); } } } if (mQueue.Count > 0) { AsbInfo info = mQueue.Peek(); if (info.Equals(asbName, assetName)) { OnLoadCallbcak(t, info); mQueue.Dequeue(); ObjPools.Recover(info); for (int i = 0; i < mQueue.Count; i++) { AsbInfo head = mQueue.Peek(); T obj = Get(head.asbName, head.assetName); if (null != obj) { OnLoadCallbcak(obj, head); mQueue.Dequeue(); ObjPools.Recover(head); } else { //不是调用序列的第一个直接返回 return(ret); } } } } } return(ret); }
//private DebugView mDebugView; //public DebugView DebugView{ get { return mDebugView; }} #region MonoBehaviour void Awake() { isRunning = true; GameConfig.Load(); initLogFile(); //初始化Platform,主要是插件相关 initGamePlatform(); ObjPools.Init(); mCorMgr = GameCoroutineManager.Instance; mResMgr = ResManager.Instance; mLuaMgr = GameLuaManager.Instance; //mUpMgr = GameUpdateManager.Instance; mUiMgr = GameUIManager.Instance; }
//private DebugView mDebugView; //public DebugView DebugView{ get { return mDebugView; }} #region MonoBehaviour void Awake() { AppVer = Application.version; isRunning = true; GameConfig.Load(); _initLogFile(); //初始化Platform,主要是插件相关 _initGamePlatform(); ObjPools.Init(); mCorMgr = CoroutineMgr.Instance; mResMgr = ResManager.Instance; mLuaMgr = LuaMgr.Instance; //mUpMgr = GameUpdateManager.Instance; mUiMgr = UIMgr.Instance; }
bool _removeUIObj(UIBase obj) { if (null != obj) { if (obj.IsStatic) { if (mStaticViews.Contains(obj)) { int index = mStaticViews.IndexOf(obj); mStaticViews.RemoveAt(index); ObjPools.Recover(mStaticViewInfos[index]); mStaticViewInfos.RemoveAt(index); } } Destroy(obj.gameObject); return(true); } return(false); }
public static int[] GetIntArry(string content) { string[] array = content.Split(','); List <int> l = ObjPools.GetListInt(); for (int i = 0; i < array.Length; i++) { int v; if (!int.TryParse(array[i], out v)) { LogFile.Warn("GetIntArry error -> colorStr:" + content); } else { l.Add(v); } } int[] ret = l.ToArray(); ObjPools.Recover(l); return(ret); }
public void ClearUIByType(RenderMode type) { Canvas c = GetCanvasByMode(type, false); if (null != c) { for (int i = 0; i < c.transform.childCount; ++i) { GameObject child = c.transform.GetChild(i).gameObject; Destroy(child); } if (RenderMode.ScreenSpaceOverlay == type) { mStackViews.Clear(); //TODO:针对static的View处理 mStaticViews.Clear(); for (int i = 0; i < mStaticViewInfos.Count; i++) { ObjPools.Recover(mStaticViewInfos[i]); } mStaticViewInfos.Clear(); } } }
private void onSelectStatusChanges() { List <int> l = ObjPools.GetListInt(); for (int i = 0; i < mItemSelectStatus.Count; i++) { if (mItemSelectStatus[i]) { l.Add(i); } } int[] arr = l.ToArray(); ObjPools.Recover(l); if (null != mOnSelectChange) { mOnSelectChange(arr); } if (null != mOnSelectChangeLua) { mOnSelectChangeLua.Call <int[]>(arr); } }