GUI.Label(new Rect(posDescriptionLeft, posDescriptionTop, descriptionWidth, tileHeight), "The description here!", titleDescription);
nextTileValue = nextTileValue + nextTileDefault;
i++;
GUI.EndScrollView();
}
}
What is the best to Archive this with NGUI, the code only draw boxes with content vertical for Scrolling.
Thank you for any help ;D MoPhat
Title: Re: New to NGUI and trying to "migrate" code from unity to it (?)
Post by: LightSky on May 07, 2014, 04:57:08 PM
The easiest way to go about this would be to have a grid created in the editor and reference it in your script. Then make a Prefab of a generic element you want to add to the scrollview. (Typically you will have the ScrollViewDrag attached) When populating the scrollview modify and instantiate the prefab using the grid as the parent. (NGUI.AddChild method) Call reposition on the grid when you are done.
-If none of your scrollview elements have a collider it is simpler to toss ScrollViewDrag on a static background.
Title: Re: New to NGUI and trying to "migrate" code from unity to it (?)
Post by: MoPhat on May 08, 2014, 03:36:20 PM
Thank you LightSky
I have created the scrollview>grid> and added new prefabs via "NGUITools.AddChild(Parent, Prefab);" and works fine and fast ;D
But i have now a few other questions.
How can i Position the prefab, should i add a Transformation on each AddChild() execution? How can i Access the objects/UI elements in the prefab to polulate it with own text/Images etc. before it added to the grid?
Thank you for the help MoPhat
Title: Re: New to NGUI and trying to "migrate" code from unity to it (?)
Post by: ArenMook on May 09, 2014, 05:29:43 AM
GameObject go = NGUITools.AddChild(parent, prefab); go.transform.localPosition = whatever;