protected override void Release(bool isShutdown) { CharKeyItem displayItem = (CharKeyItem)Target; if (displayItem == null) { return; } Object.Destroy(displayItem.gameObject); }
private void Update() { for (int i = m_ActiveCharKeyItems.Count - 1; i >= 0; i--) { CharKeyItem displayItem = m_ActiveCharKeyItems[i]; if (displayItem.Refresh()) { continue; } //HideCharKey(displayItem); } }
//public void ShowCharKey(int entity, float fromHPRatio, float toHPRatio) public void ShowCharKey(int entity) { if (entity == null) { Log.Warning("Entity is invalid."); return; } CharKeyItem displayItem = GetActiveCharKeyItem(entity); if (displayItem == null) { displayItem = CreateCharKeyItem(entity); m_ActiveCharKeyItems.Add(displayItem); } //displayItem.Init(entity, m_CachedCanvas, fromHPRatio, toHPRatio); displayItem.Init(entity, cachedTypingForm); }
private CharKeyItem CreateCharKeyItem(int entity) { CharKeyItem displayItem = null; CharKeyItemObject displayItemObject = m_CharKeyItemObjectPool.Spawn(); if (displayItemObject != null) { displayItem = (CharKeyItem)displayItemObject.Target; } else { displayItem = Instantiate(m_CharKeyItemTemplate); Transform transform = displayItem.GetComponent <Transform>(); transform.SetParent(m_CharKeyInstanceRoot); transform.localScale = Vector3.one; m_CharKeyItemObjectPool.Register(CharKeyItemObject.Create(displayItem), true); } return(displayItem); }
private void HideCharKey(CharKeyItem displayItem) { displayItem.Reset(); m_ActiveCharKeyItems.Remove(displayItem); m_CharKeyItemObjectPool.Unspawn(displayItem); }