private void PutHUDInPool(PlayerHeadBarHud hud) { hud.mDMono.transform.SetParent(mDMono.transform); hud.mDMono.gameObject.CustomSetActive(false); hudsPool.Push(hud); hud.recycleCallback = null; }
private PlayerHeadBarHud GetHUDFromPool() { PlayerHeadBarHud hud = null; if (hudsPool.Count > 0) { hud = hudsPool.Pop(); hud.mDMono.gameObject.CustomSetActive(true); } else { EB.Debug.Log("HUD pool length too small. GetHUDFromPool() called but pool is empty. New HUD instance created"); hud = CreateHUD(); } if (hud == null) { return(null); } hud.recycleCallback = delegate() { PutHUDInPool(hud); }; return(hud); }
private PlayerHeadBarHud CreateHUD() { if (HUDTemplate == null) { EB.Debug.LogError("HUDTemplate is null"); return(null); } PlayerHeadBarHud hud = Object.Instantiate <GameObject>(HUDTemplate).GetMonoILRComponent <PlayerHeadBarHud>(); hud.mDMono.transform.SetParent(mDMono.transform); hud.mDMono.transform.localScale = new Vector3(5000f, 5000f, 0f); return(hud); }