public override void init(GameLayout layout, GameObject go, txUIObject parent) { base.init(layout, go, parent); 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) { 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); } }
public void assignWindow(txNGUIStaticSprite root, string trackName) { mScript.newObject(out mTrack, root, trackName); mScript.newObject(out mChecked, mTrack, "Cheaked", 0); mScript.newObject(out mLabel, mChecked, "Label", 1); mScript.newObject(out mTexture, mTrack, "Texture"); mScript.newObject(out mUIGrid, mChecked, "UIGrid"); for (int i = 0; i < mUIGrid.getChildCount(); ++i) { txUIObject star = mScript.newObject(out star, mUIGrid, "Star" + i, 0); mStarList.Add(star); } mTrackName = trackName; }