protected IRuneDetailObj GetOrCreateRuneDetailObj(RuneDetailObjType type, Transform parent) { if (mObjPool != null && mObjPool.Count > 0) { for (int i = 0; i < mObjPool.Count; i++) { if (mObjPool[i].isInUse) { continue; } if (mObjPool[i].objType != type) { continue; } mObjPool[i].isInUse = true; return(mObjPool[i].obj); } } IRuneDetailObj detailObj = RuneFactory.Create(type, parent); RuneDetailCommonObjData objData = new RuneDetailCommonObjData(); objData.isInUse = true; objData.obj = detailObj; objData.objType = type; mObjPool.Add(objData); return(detailObj); }
public static IRuneDetailObj Create(RuneDetailObjType type, Transform parent) { switch (type) { case RuneDetailObjType.ScrollRect: RuneDetailScrollRect lahyout = new RuneDetailScrollRect(RuneManager.Inst.RuneDetail.GetObjClone(RuneDetailObjType.ScrollRect)); lahyout.SetParent(parent); return(lahyout); case RuneDetailObjType.Title: RuneDetailTitle title = new RuneDetailTitle(RuneManager.Inst.RuneDetail.GetObjClone(RuneDetailObjType.Title)); title.SetParent(parent); return(title); case RuneDetailObjType.Content: RuneDetailContent content = new RuneDetailContent(RuneManager.Inst.RuneDetail.GetObjClone(RuneDetailObjType.Content)); content.SetParent(parent); return(content); case RuneDetailObjType.TwoAttri: RuneDetailTwoAttri twoAttri = new RuneDetailTwoAttri(RuneManager.Inst.RuneDetail.GetObjClone(RuneDetailObjType.TwoAttri)); twoAttri.SetParent(parent); return(twoAttri); case RuneDetailObjType.ThreAttri: RuneDetailThreeAtrri threeAttri = new RuneDetailThreeAtrri(RuneManager.Inst.RuneDetail.GetObjClone(RuneDetailObjType.ThreAttri)); threeAttri.SetParent(parent); return(threeAttri); default: return(null); } }
public GameObject GetObjClone(RuneDetailObjType objType) { switch (objType) { case RuneDetailObjType.ScrollRect: return(UIResourceMgr.Clone(mScrollRectObj) as GameObject); case RuneDetailObjType.Title: return(UIResourceMgr.Clone(mTitleObj) as GameObject); case RuneDetailObjType.Content: return(UIResourceMgr.Clone(mContentObj) as GameObject); case RuneDetailObjType.TwoAttri: return(UIResourceMgr.Clone(mTwoAttriObj) as GameObject); case RuneDetailObjType.ThreAttri: return(UIResourceMgr.Clone(mThreeAttriObj) as GameObject); default: Debug.LogError("不存在的类型:" + objType); return(null); } }