コード例 #1
0
    ///<从IDX(包含)往后的所有ITEM扔到池子里去
    void _CachedFreeGridItem(int idx)
    {
        int gsize = cGrid.transform.childCount;

        if (idx > gsize)
        {
            return; //
        }
        for (int i = 0, c = gsize - idx; i < c; ++i)
        {
            Transform tf = cGrid.RemoveChild(idx);
            if (tf)
            {
                _Free(tf.gameObject);
            }
        }
    }
コード例 #2
0
    private void UpdateChatList(COM_ContactInfo contact)
    {
        List <COM_Chat> strArr = FriendSystem.Instance().ChatCache(contact);

        for (int i = 0; i < chatCellList.Count; i++)
        {
            //chatGrid.RemoveChild(chatCellList[i].transform);
            cGrid.RemoveChild(chatCellList[i].transform);
            chatCellList[i].transform.parent = null;
            chatCellList[i].gameObject.SetActive(false);
            GameObject.Destroy(chatCellList[i]);
        }
        chatCellList.Clear();
        //	return;
        //}
        if (strArr != null && strArr.Count > 0)
        {
            for (int i = 0; i < strArr.Count; i++)
            {
                if (!strArr[i].isMe)
                {
                    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();
                    Filt(ref strArr[i].content_, 0, 1);
                    info.content_    = strArr[i].content_;
                    info.ck_         = ChatKind.CK_Friend;
                    info.playerName_ = contact.name_;
                    info.assetId_    = (ushort)contact.assetId_;
                    cmi.Info         = info;
                    cmi._LChatKindBackground.gameObject.SetActive(false);
                    cmi._RChatKindBackground.gameObject.SetActive(false);
                    chatCellList.Add(tf);
                }
                else
                {
                    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();
                    Filt(ref strArr[i].content_, 0, 1);
                    info.content_    = strArr[i].content_;
                    info.ck_         = ChatKind.CK_Friend;
                    info.playerName_ = GamePlayer.Instance.InstName;
                    info.assetId_    = (ushort)GamePlayer.Instance.GetIprop(PropertyType.PT_AssetId);
                    cmi.Info         = info;
                    cmi._LChatKindBackground.gameObject.SetActive(false);
                    cmi._RChatKindBackground.gameObject.SetActive(false);
                    chatCellList.Add(tf);
                }
            }
        }
        cGrid.Reposition();
        scrollBar.value = 1;
        //FriendSystem.Instance ().ChatDict.Remove(contact.name_);
    }