예제 #1
0
    void ResetList(int type)
    {
        if (mChatStr[type].Count >= mChatItem.Count)
        {
            for (int i = 0; i < mChatItem.Count; i++)
            {
                string[] strList = mChatStr[type][i].Split('&');
                mChatItem[i].SetText(strList[0], strList[1]);
            }
            for (int i = mChatItem.Count; i < mChatStr[type].Count; i++)
            {
                ChartItem_N AddItem = Instantiate(mPrefab) as ChartItem_N;
                AddItem.gameObject.name         = "ChatItem" + mNumCount;
                AddItem.transform.parent        = mListTable.transform;
                AddItem.transform.localPosition = Vector3.zero;
                AddItem.transform.localRotation = Quaternion.identity;
                AddItem.transform.localScale    = Vector3.one;

                string[] strList = mChatStr[type][i].Split('&');
                AddItem.SetText(strList[0], strList[1]);
                mChatItem.Add(AddItem);
            }
        }
        else
        {
            for (int i = 0; i < mChatStr[type].Count; i++)
            {
                string[] strList = mChatStr[type][i].Split('&');
                mChatItem[i].SetText(strList[0], strList[1]);
            }
            for (int i = mChatItem.Count - 1; i >= mChatStr[type].Count; i--)
            {
                mChatItem[i].transform.parent = null;
                Destroy(mChatItem[i].gameObject);
                mChatItem.RemoveAt(i);
            }
        }
        mListTable.Reposition();
        mScrollBar.scrollValue = 1;
    }
예제 #2
0
 void AddChatItem(string name, string chatString, int type)
 {
     mChatStr[type].Add(name + "&" + chatString);
     if (mChatType == type)
     {
         ChartItem_N AddItem = Instantiate(mPrefab) as ChartItem_N;
         AddItem.gameObject.name         = "ChatItem" + mNumCount;
         AddItem.transform.parent        = mListTable.transform;
         AddItem.transform.localPosition = Vector3.zero;
         AddItem.transform.localRotation = Quaternion.identity;
         AddItem.transform.localScale    = Vector3.one;
         AddItem.SetText(name, chatString);
         mChatItem.Add(AddItem);
         if (mChatItem.Count > MaxListLenth)
         {
             mChatItem[0].transform.parent = null;
             Destroy(mChatItem[0].gameObject);
             mChatItem.RemoveAt(0);
             mChatStr[type].RemoveAt(0);
         }
         mListTable.Reposition();
         mScrollBar.scrollValue = 1;
     }
     mNumCount++;
     if (mNumCount > 200000000)
     {
         mNumCount = 0;
         for (int i = mChatItem.Count - 1; i >= 0; i--)
         {
             mChatItem[i].transform.parent = null;
             Destroy(mChatItem[i].gameObject);
             mChatItem.RemoveAt(i);
         }
         ResetList(mChatType);
     }
 }