Exemplo n.º 1
0
        public void OnChatMessageUpdate()
        {
            if (!contentView)
            {
                return;
            }

            List <SChatMessageInfo> msgList = LogicDataCenter.chatMessageManager.MessageList;

            if (msgList == null)
            {
                return;
            }

            //if (LogicDataCenter.chatMessageManager.MsgIsOverLoad)
            //{
            //contentView.removeFirstComponentsItem();
            //}

            contentView.DataSource.BeginUpdate();

            contentView.DataSource.Clear();
            for (int i = 0; i < msgList.Count; ++i)
            {
                ChatBoxContentItemData data = new ChatBoxContentItemData();
                data.info = msgList[i];
                contentView.DataSource.Add(data);
            }

            contentView.DataSource.EndUpdate();

            contentView.GetScrollRect().normalizedPosition = new Vector2(0f, 0f);

            m_ChatBoxState.OnNewChatMsg();
        }
Exemplo n.º 2
0
        public void SetData(ChatBoxContentItemData data)
        {
            // 重复SetData的问题先这么写,以后再看
            RectTransform selfTrans = this.RectTransform;

            if (selfTrans == null)
            {
                return;
            }

            if (m_curSequenceID == data.info.sequenceID && m_curWidth == selfTrans.rect.width)
            {
                return;
            }
            m_curSequenceID = data.info.sequenceID;
            m_curWidth      = selfTrans.rect.width;

            ChatContentItem item = gameObject.GetComponent <ChatContentItem>();

            if (item != null)
            {
                ChatContentItemData itemData = new ChatContentItemData();
                itemData.objList = data.info.objList;
                item.SetData(itemData);

                m_Height = item.Height;
            }
            else
            {
                Debug.LogError("item == null, This GameObject have no ChatContentItem component.");
            }
        }