Пример #1
0
    public override void init(GameObject go, txUIObject parent)
    {
        base.init(go, parent);
        mScrollView = getUnityComponent <UIScrollView>();
        int childCount = getChildCount();

        for (int i = 0; i < childCount; ++i)
        {
            GameObject gridGo = mTransform.GetChild(i).gameObject;
            if (gridGo.GetComponent <UIGrid>() != null)
            {
                mLayout.getScript().newObject(out mGrid, this, gridGo.name);
                break;
            }
        }
        if (mGrid == null)
        {
            logError("scroll view window must have a child with grid compoent!");
        }
        // 查找grid下已经挂接的物体
        int itemCount = mGrid.getChildCount();

        for (int i = 0; i < itemCount; ++i)
        {
            GameObject child = mGrid.getChild(i);
            txUIObject item  = mLayout.getScript().newObject(out item, mGrid, child.name);
            mItemList.Add(item);
        }
    }
Пример #2
0
    public override void init(GameLayout layout, GameObject go)
    {
        base.init(layout, go);
        mScrollView = go.GetComponent <UIScrollView>();
        int childCount = mScrollView.transform.childCount;

        for (int i = 0; i < childCount; ++i)
        {
            GameObject gridGo = mScrollView.transform.GetChild(i).gameObject;
            if (gridGo.GetComponent <UIGrid>() != null)
            {
                mGrid = mLayout.getScript().newObject <txUIObject>(this, gridGo.name, -1);
                break;
            }
        }
        if (mGrid == null)
        {
            UnityUtility.logError("error : scroll view window must have a child with grid compoent!");
        }
        // 查找grid下已经挂接的物体
        int itemCount = mGrid.getChildCount();

        for (int i = 0; i < itemCount; ++i)
        {
            GameObject child = mGrid.getChild(i);
            txUIObject item  = mLayout.getScript().newObject <txUIObject>(mGrid, child.name, -1);
            mItemList.Add(item);
        }
    }