private void _addChat(GC_ChatMsg _data) { eChatTarget type = eChatTarget.eChatTarget_other; PlayerInfoBase player = null; if (_data.PlayerID == MainPlayer.Instance.PlayerInfo.PlayerID) { type = eChatTarget.eChatTarget_mine; player = MainPlayer.Instance.PlayerInfo; } else { type = eChatTarget.eChatTarget_other; player = LobbySystem.Instance.GetPlayerInfo(_data.PlayerID); } _addChat(type, player.PlayerName, player.Level, _data.Chat); }
private GameObject _getFreeObj(eChatTarget _type) { GameObject obj = null; switch (_type) { case eChatTarget.eChatTarget_other: if (m_free_other.Count == 0) { obj = Instantiate(m_other_template); } else { obj = m_free_other.Pop(); } break; case eChatTarget.eChatTarget_mine: if (m_free_mine.Count == 0) { obj = Instantiate(m_mine_template); } else { obj = m_free_mine.Pop(); } break; case eChatTarget.eChatTarget_notice: if (m_free_notice.Count == 0) { obj = Instantiate(m_notice_template); } else { obj = m_free_notice.Pop(); } break; } return(obj); }
private void _addChat(eChatTarget _type, string _name, Int32 _level, string _content) { GameObject obj = null; obj = _getFreeObj(_type); switch (_type) { case eChatTarget.eChatTarget_other: case eChatTarget.eChatTarget_mine: obj.transform.FindChild("text_name").GetComponent <Text>().text = _name; obj.transform.FindChild("Image/text_chat").GetComponent <Text>().text = _content; break; case eChatTarget.eChatTarget_notice: obj.transform.FindChild("Image/text_chat").GetComponent <Text>().text = _content; break; } obj.SetActive(true); obj.transform.SetParent(m_container.transform, false); if (m_container.transform.childCount > 30) { _addFreeObj(m_container.transform.GetChild(0).gameObject); } }