Exemple #1
0
    public static bool RemoveChild(this UITable table, Transform t)
    {
        List <Transform> list = table.GetChildListEx();

        if (list.Remove(t))
        {
            t.parent = null;
            GameObject.Destroy(t.gameObject);
            table.repositionNow = true;
            return(true);
        }
        return(false);
    }
Exemple #2
0
    private void AddItem(int i)
    {
        var childList = mGrid.GetChildListEx();

        if (childList.Count == transform.childCount)
        {
            AddNewItem(i);
        }
        else
        {
            for (var j = 0; j < transform.childCount; j++)
            {
                var t = transform.GetChild(j);
                var b = t.GetComponent <BindDataRoot>();

                if (b.IsBind == false)
                {
                    t.gameObject.SetActive(true);
                    if (mGrid.enabled == false)
                    {
                        mGrid.enabled = true;
                    }
                    mGrid.AddChild(t);
                    break;
                }
            }
            var mList = Source as IList;
            childList = mGrid.GetChildListEx();
            for (var j = i; j < childList.Count; j++)
            {
                var t       = childList[j];
                var binding = t.GetComponent <BindDataRoot>();
                if (binding != null)
                {
                    binding.SetBindDataSource(mList[j]);
                }

                var itemLogic = t.GetComponent <ListItemLogic>();
                if (itemLogic != null)
                {
                    itemLogic.Index = j;
                    itemLogic.Item  = mList[j];
                }
            }
        }
    }