コード例 #1
0
    //private void DisposeItem(List<GListItem> items)
    //{
    //    if (items.Count > 0)
    //    {
    //        GListItem item = items[items.Count - 1];
    //        if (item != null)
    //        {
    //            if (_pool.PutIn(item))
    //            {
    //                GNewUITools.SetVisible(item.RectTrans, false);
    //            }
    //            else
    //            {
    //                Destroy(item.gameObject);
    //            }
    //        }
    //        items.RemoveAt(items.Count - 1);
    //    }
    //}

    private void UpdateItem(List <GListItem> items, int pos, int index)
    {
        if (items.Count > pos)
        {
            //Debug.Log("UpdateItem " + pos + " " + index);
            if (items[pos] == null)
            {
                items[pos] = TryCreateItem();
            }

            GListItem item = items[pos];

            //dont want to wast time here
            //SetPivotAnchor(item.RectTrans, _Align);

            AdjustItemAnchor(item.RectTrans);

            item.SetPosition(Index2Pos2(index, item.RectTrans));
            //item.gameObject.SetActive(id < this._DataCount);
            //item.SetLocalPosition(Index2Pos2(index, item.RectTrans));

            item.UpdateItem(index, true);

            if (SingleSelect)
            {
                item.IsOn = (_SingleSelectIndex == index);
            }
        }
    }
コード例 #2
0
ファイル: GNewListBase.cs プロジェクト: frozen4/UnityPlus
    public void Preview(int count)
    {
        SafeInit();

        for (int i = 0; i < _viewItems.Count; i++)
        {
            Destroy(_viewItems[i].gameObject);
        }
        _viewItems.Clear();

        this._ItemCount = count;
        RecalculateBound();

        //_CellRect.localScale = Vector3.zero;

        for (int i = 0; i < _ItemCount; i++)
        {
            GListItem g_li = TryCreateItem();
            if (g_li != null)
            {
                SetPivotAnchor(g_li.RectTrans, _Align);
                g_li.RectTrans.anchoredPosition = Index2Pos2(i, g_li.RectTrans);
            }
            g_li.UpdateItem(i);
            //PostSetupItem(g_li);
            _viewItems.Add(g_li);
        }

        //_CellRect.localScale = Vector3.zero;
        //_CellRect.gameObject.SetActive(false);
        //PlayEffect();
    }
コード例 #3
0
ファイル: GNewLayoutTable.cs プロジェクト: frozen4/UnityPlus
    public void AddItem(int index)
    {
        if (index < 0 || index > _ItemCount)
        {
            HobaDebuger.LogWarning("<GNewLayoutTable> AddItem: index out of range! ");
            return;
        }

        //InsertItem(_ViewItems, index);

        GListItem item = null;

        item = TryCreateItem();
        if (item != null)
        {
            _ViewItems.Insert(index, item);
            _ItemCount = _ViewItems.Count;

            //OnAddItem(item.gameObject, item.index);
            item.UpdateItem(index, true);

            for (int i = index + 1, max = _ViewItems.Count; i < max; i++)
            {
                _ViewItems[i].UpdateItem(i, false);
                _ViewItems[i].RectTrans.SetAsLastSibling();
            }

            if (_MainSelection >= index)
            {
                _MainSelection += 1;
            }

            //RepositionItems();
        }
    }
コード例 #4
0
ファイル: GNewTableBase.cs プロジェクト: frozen4/UnityPlus
    protected virtual void UpdateItem(List <GListItem> items, int pos)
    {
        //Debug.Log("UpdateItem " + pos);

        GListItem item = null;

        if (items.Count > pos)
        {
            item = items[pos];
        }
        else
        {
            item = TryCreateItem();
            if (item != null)
            {
                items.Add(item);
                //OnAddItem(item.gameObject, item.index);
            }
        }

        if (item != null)
        {
            item.UpdateItem(pos, true);
        }
    }
コード例 #5
0
ファイル: GNewList.cs プロジェクト: frozen4/UnityPlus
    //private void DisposeItem(List<GListItem> items)
    //{
    //    if (items.Count > 0)
    //    {
    //        GListItem item = items[items.Count - 1];
    //        if (item != null)
    //        {
    //            if (_pool.PutIn(item))
    //            {
    //                GNewUITools.SetVisible(item.RectTrans, false);
    //            }
    //            else
    //            {
    //                Destroy(item.gameObject);
    //            }
    //        }

    //        items.RemoveAt(items.Count - 1);
    //    }
    //}

    private void UpdateItem(List <GListItem> items, int pos, bool is_need_init)
    {
        //Debug.Log("UpdateItem " + pos);

        GListItem item = null;

        if (items.Count > pos)
        {
            item = items[pos];
        }
        else
        {
            item = TryCreateItem();
            items.Add(item);
            //OnAddItem(item.gameObject, item.index);
        }

        AdjustItemAnchor(item.RectTrans);
        item.SetPosition(Index2Pos2(pos, item.RectTrans));
        //item.RectTrans.anchoredPosition = Index2Pos2(pos, item.RectTrans);
        //item.SetLocalPosition(Index2Pos2(pos, item.RectTrans));

        item.UpdateItem(pos, is_need_init);

        if (SingleSelect)
        {
            item.IsOn = (_SingleSelectIndex == pos);
        }
    }
コード例 #6
0
ファイル: GNewLayoutTable.cs プロジェクト: frozen4/UnityPlus
    public void RefreshItem(int i_index)
    {
        GListItem git = GetListItem(i_index);

        if (git != null)
        {
            //OnShowItem(git.gameObject, git.index);
            git.UpdateItem(i_index, true);
        }
    }