using UnityEngine; using UnityEngine.UI; using System; using System.Collections; using System.Collections.Generic; using Games.GlobeDefine; using Games.ChatHistory; using Games.Item; using GCGame.Table; using GCGame; using Module.Log; using Google.ProtocolBuffers; public class ChatHistoryLogicHelper : ChatHistoryLogic { public GameObject _ChatHelperPrefabMy; public GameObject _ChatHelperPrefabAI; public void OnDisable() { PlayerPreferenceData.SetFriendChatHistory(GameManager.gameManager.PlayerDataPool.ChatHistory.FriendChatList); } public void Update() { ContentUpdate(); } #region chat history public void OnReceiveChat(ChatHistoryItem history) { HandleChatHistory(history); } protected override void HandleChatHistory(ChatHistoryItem history, bool isShowLast = false) { if (history.SenderGuid == GlobeVar.SYSFRIEND_GUID) { var chatLogInfo = GetIdleChatLogItem(_ChatHelperPrefabAI); chatLogInfo.SetChatLog(history); } else { var chatLogInfo = GetIdleChatLogItem(_ChatHelperPrefabMy); chatLogInfo.SetChatLog(history); } } #endregion #region content pos private float _LastContentHeight; public void ContentUpdate() { //if (_LastContentHeight == 0) //{ // _LastContentHeight = _ChatLogContent.rect.height; // return; //} if (_LastContentHeight != _ChatLogContent.rect.height) { float delta = _ChatLogContent.rect.height - _LastContentHeight; _LastContentHeight = _ChatLogContent.rect.height; if (delta > 500) { _ChatLogContent.anchoredPosition = new Vector2(0, - delta - 150); } } } #endregion }