public ChatEmojiItem GetChatEmojiItem() { if (mCacheStack.Count == 0) { ChatEmojiItem temp = new ChatEmojiItem(); temp.SetAction(mUpdateContentAction); temp.InitItem(mOriginGo); return(temp); } return(mCacheStack.Pop()); }
public ChatEmojiCache(GameObject originGo, Action <ChatEmojiItem, ChatEmojiPos, Vector2, Transform> UpdateContentAction, int initCount = 20) { mOriginGo = originGo; originGo.SetActive(false); this.mUpdateContentAction = UpdateContentAction; for (int i = 0; i < initCount; ++i) { ChatEmojiItem temp = new ChatEmojiItem(); temp.SetAction(mUpdateContentAction); temp.InitItem(mOriginGo); mCacheStack.Push(temp); } }