/// <summary> /// 添加内容到聊天窗口 /// </summary> /// <param name="text"></param> private void Add(string name, string nameColor, string text, string textColor, byte[] bytes) { GameObject go; if (mList.Count >= MaxCount) { go = mList[0]; mList.Remove(go); } else { go = Instantiate(ChatCell) as GameObject; } ChatItem cell = go.GetComponent <ChatItem>(); go.transform.parent = grid.transform; go.transform.localScale = ChatCell.transform.localScale; cell.nameColor = nameColor; cell.infoColor = textColor; cell.nameText = name; cell.text = text; mList.Add(go); grid.Reposition(); scrollBar.value = 1; }
void Update() { if (istargetPrass) { if (Input.GetMouseButtonDown(0)) { mousePosition_Y = Input.mousePosition.y; } if (Input.GetMouseButton(0)) { if (Input.mousePosition.y - mousePosition_Y > 80) { isCanel = true; } } tt = Mathf.Max(0, maxTime - (Time.realtimeSinceStartup - PrassTime)); if (tt == 0) { yuyinTips.SetActive(false); int audiolen = Mathf.RoundToInt(Time.realtimeSinceStartup - PrassTime); ChatSystem.StopRecord(); if (ChatSystem.AsyncGetCallBack == null) { ChatSystem.AsyncGetCallBack = delegate(byte[] datas) { audioChat_ = new COM_Chat(); audioChat_.audio_ = datas; audioChat_.isAudio_ = true; audioChat_.audioTime_ = audiolen; //int le = Mathf.RoundToInt(ChatSystem.GetClipLength(audioChat_.audio_)); ChatSystem.SendToServer(_SendChatKind, "", "", audioChat_.audio_, audioChat_.audioTime_); ClientLog.Instance.Log("audioChat_.audio_====+++++=" + audioChat_.audio_.Length); ischaoshi = true; istargetPrass = false; audioChat_ = null; }; ChatSystem.AsyncGet(); } } } if (!_IsDirty) { return; } if (!ChatSystem.GetChannelInfo(_OpenChannels, ref _ChannelInfo, ref index)) { return; } if (_ChannelInfo.Count == 0) { //木有 _CachedFreeGridItem(0); _IsDirty = false; return; } for (int i = 0; i < _ChannelInfo.Count; ++i) { _MakedGridItem(i, _ChannelInfo[i]); //链表下标访问 是不是很 } _CachedFreeGridItem(_ChannelInfo.Count); //清理多余物件 // GlobalInstanceFunction.Instance.Invoke(() => // { cGrid.Reposition(); if (!isLock) { _Sb.value = 1; } // }, 2); _IsDirty = false; }
void OnLineEvent(bool line) { if (string.IsNullOrEmpty(friendChatLab.text.Trim())) { PopText.Instance.Show(LanguageManager.instance.GetValue("bunengweikong")); return; } if (!line) { PopText.Instance.Show(LanguageManager.instance.GetValue("frinedonline")); return; } else if (chat_com != null) { chat_com.ck_ = ChatKind.CK_Friend; Filt(ref chat_com.content_, 0, 1); NetConnection.Instance.sendChat(chat_com, _selectFriend.name_); if (chat_com.content_.Length > 30) { //PopText.Instance.Show(LanguageManager.instance.GetValue("chatLineMax")); //return; } //COM_Chat comC = new COM_Chat(); chat_com.ck_ = ChatKind.CK_Friend; chat_com.content_ = friendChatLab.text; chat_com.isMe = true; // NetConnection.Instance.sendChat (comC,_selectFriend.name_); GameObject tf = null; tf = GameObject.Instantiate(_GridItem) as GameObject; cGrid.AddChild(tf.transform); tf.transform.localScale = Vector3.one; tf.gameObject.SetActive(true); ChatMaxCell cmi = tf.gameObject.GetComponent <ChatMaxCell>(); COM_ChatInfo info = new COM_ChatInfo(); // (COM_ChatInfo)comC ; info.playerName_ = GamePlayer.Instance.InstName; info.content_ = friendChatLab.text; Filt(ref info.content_, 0, 1); info.ck_ = ChatKind.CK_Friend; info.assetId_ = (ushort)GamePlayer.Instance.GetIprop(PropertyType.PT_AssetId); cmi.Info = info; cmi._LChatKindBackground.gameObject.SetActive(false); cmi._RChatKindBackground.gameObject.SetActive(false); chat_com = null; FriendSystem.Instance().addMyChat(_selectFriend.name_, chat_com); chatCellList.Add(tf); friendChatLab.text = ""; chatInput.value = ""; } else { if (string.IsNullOrEmpty(friendChatLab.text.Trim())) { PopText.Instance.Show(LanguageManager.instance.GetValue("bunengweikong")); return; } if (friendChatLab.text.Length > 30) { //PopText.Instance.Show(LanguageManager.instance.GetValue("chatLineMax")); //return; } COM_Chat comC = new COM_Chat(); comC.ck_ = ChatKind.CK_Friend; comC.content_ = friendChatLab.text; Filt(ref comC.content_, 0, 1); NetConnection.Instance.sendChat(comC, _selectFriend.name_); GameObject tf = null; tf = GameObject.Instantiate(_GridItem) as GameObject; cGrid.AddChild(tf.transform); tf.transform.localScale = Vector3.one; tf.gameObject.SetActive(true); ChatMaxCell cmi = tf.gameObject.GetComponent <ChatMaxCell>(); COM_ChatInfo info = new COM_ChatInfo(); info.playerName_ = GamePlayer.Instance.InstName; info.content_ = friendChatLab.text; Filt(ref info.content_, 0, 1); info.ck_ = ChatKind.CK_Friend; info.assetId_ = (ushort)GamePlayer.Instance.GetIprop(PropertyType.PT_AssetId); cmi.Info = info; cmi._LChatKindBackground.gameObject.SetActive(false); cmi._RChatKindBackground.gameObject.SetActive(false); comC.isMe = true; friendChatLab.text = ""; chatInput.value = ""; FriendSystem.Instance().addMyChat(_selectFriend.name_, comC); chatCellList.Add(tf); } cGrid.Reposition(); scrollBar.value = 1; }