Exemple #1
0
    private void MoveGridItem(bool isTopToBottom)
    {
        List <LoopGridLuaItem> items;
        // 判断是否是 上(左)移动到下(右)
        int curIndex;
        int itemIndex;
        int sign;

        if (isTopToBottom)
        {
            curIndex  = m_maxIndex + 1;
            itemIndex = 0;
            sign      = 1;
        }
        else
        {
            curIndex  = m_minIndex - 1;
            itemIndex = m_items.Count - 1;
            sign      = -1;
        }

        items = m_items[itemIndex];

        int targetIndex = itemIndex == 0 ? m_items.Count - 1 : 0;

        m_items.Remove(items);
        m_items.Insert(targetIndex, items);

        for (int i = 0; i < items.Count; i++)
        {
            if (curIndex * maxPerLine + i < 0)
            {
                break;
            }
            if (curIndex * maxPerLine + i > m_dataCount - 1)
            {
                break;
            }
            LoopGridLuaItem item = items[i];
            item.FillItem(curIndex * maxPerLine + i, curIndex, i);
        }

        m_minIndex += sign;
        m_maxIndex += sign;
    }
Exemple #2
0
    private LoopGridLuaItem AddOneItem(int gridIndex, int lineIndex)
    {
        GameObject go = GetGridItem();
        var        cb = go.GetComponent <UIToggle>();

        if (selectLimit == 1)
        {
            if (cb != null)
            {
                cb.group = 1024;
            }
        }
        else if (selectLimit > 1)
        {
            if (cb != null)
            {
                cb.group = 0;
            }
        }

        LoopGridLuaItem item = go.GetComponent <LoopGridLuaItem>();

        if (item == null || !item.inited)
        {
            if (item == null)
            {
                item = go.AddComponent <LoopGridLuaItem>();
            }
            item.grid = this;
            LuaTable bind = CreateFillTable();
            item.SetFirstItemData(m_dataCount, gridIndex * maxPerLine + lineIndex);
            item.FindItem(bind);
        }

        item.transform.parent     = transform;
        item.transform.localScale = itemTemplate.transform.localScale;
        item.gameObject.SetActive(true);
        item.FillItem(gridIndex * maxPerLine + lineIndex, gridIndex, lineIndex);
        return(item);
    }