コード例 #1
0
    private void DelItemFromPanel(int index)
    {
        int maxIndex = -1;
        int minIndex = int.MaxValue;

        for (int i = _itemList.Count; i > 0; i--)
        {
            UIScrollIndex item = _itemList[i - 1];
            if (item.Index == index)
            {
                GameObject.Destroy(item.gameObject);
                _itemList.Remove(item);
            }
            if (item.Index > maxIndex)
            {
                maxIndex = item.Index;
            }
            if (item.Index < minIndex)
            {
                minIndex = item.Index;
            }
            if (item.Index > index)
            {
                item.Index -= 1;
            }
        }
        if (maxIndex < DataCount - 1)
        {
            CreateItem(maxIndex);
        }
    }
コード例 #2
0
 private void AddItemIntoPanel(int index)
 {
     for (int i = 0; i < _itemList.Count; i++)
     {
         UIScrollIndex item = _itemList[i];
         if (item.Index >= index)
         {
             item.Index += 1;
         }
     }
     CreateItem(index);
 }
コード例 #3
0
    public UIScrollIndex AddItem(MsgChat msg)
    {
        UIScrollIndex item = CreateItem(mesNum);

        _content.GetComponent <RectTransform>().anchoredPosition = GetContentPos();
        _content.GetComponent <RectTransform>().sizeDelta        = GetContentSize();
        item.mesIndex.text = mesNum.ToString();
        item.mesText.text  = DateTime.Now.ToLongTimeString().ToString() + msg.userName + ":" + msg.chatMessage;
        _mesText.Add(item.mesText.text);
        mesNum++;
        return(item);
    }
コード例 #4
0
    public void OnValueChange(Vector2 pos)
    {
        int index = GetPosIndex();

        if (_index != index && index > -1)
        {
            _index = index;
            for (int i = _itemList.Count; i > 0; i--)
            {
                UIScrollIndex item = _itemList[i - 1];
                if (item.Index < index || (item.Index >= index + viewCount))
                {
                    //GameObject.Destroy(item.gameObject);
                    _itemList.Remove(item);
                    _unUsedQueue.Enqueue(item);
                }
            }
            for (int i = _index; i < _index + viewCount; i++)
            {
                if (i < 0)
                {
                    continue;
                }
                // if (i > _dataCount - 1) continue;//超过100条
                if (i > mesNum - 1)
                {
                    continue;
                }
                bool isOk = false;
                foreach (UIScrollIndex item in _itemList)
                {
                    if (item.Index == i)
                    {
                        isOk = true;
                    }
                }
                if (isOk)
                {
                    continue;
                }
                UIScrollIndex itemBase = CreateItem(i);
                itemBase.mesText.text = _mesText[i];
            }
        }
    }