public T Create(Transform parent = null) { ObjectRecycler <T> .Entry entry = this._objectPool.Find((ObjectRecycler <T> .Entry x) => !x.used); if (entry != null) { if (parent) { entry.value.transform.parent = parent; } entry.value.transform.localScale = Vector3.one; PerfTools.SetVisible(entry.value.transform, true); entry.used = true; return(entry.value); } T t = (T)((object)null); if (this._getMethod != null) { t = this._getMethod(); if (t) { t.transform.parent = parent; PerfTools.SetVisible(t.transform, true); t.transform.localScale = Vector3.one; ObjectRecycler <T> .Entry item = new ObjectRecycler <T> .Entry { name = t.name, value = t, used = true }; this._objectPool.Add(item); } } return(t); }
public CharacterView() { this.WinResCfg = new WinResurceCfg(true, true, "CharacterView"); this._hudTextRecycler = new ObjectRecycler <HUDText>(new Func <HUDText>(this.NewHudText), null); this._jumpwordRecycler = new ObjectRecycler <UIJumpWord>(delegate { UIJumpWord uIJumpWord = ResourceManager.LoadPath <UIJumpWord>("Prefab/UI/HUDText/JumpWord", null, 0); if (uIJumpWord == null) { ClientLogger.Error("UIJumpWordPrefab is Null跳字预设为空(没有找到)"); return(null); } return(UnityEngine.Object.Instantiate(uIJumpWord) as UIJumpWord); }, new Action <UIJumpWord>(UnityEngine.Object.Destroy)); }
public void Release(T comp) { if (!comp) { return; } ObjectRecycler <T> .Entry entry = this._objectPool.Find((ObjectRecycler <T> .Entry x) => comp == x.value); if (entry != null) { PerfTools.SetVisible(comp.transform, false); comp.transform.SetParent(this._recycleParent); entry.used = false; } else { ClientLogger.Error("release " + comp.name); } }