Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Vicas on August 12, 2014, 07:29:09 AM
-
I have a game that upon load spawns a whole range of PreFabs that all holds different UILabels.
Right now, each of these have their own UILabel, since this is added automatically by NGUI, when I add a UILabel to a simple GameObject that is going to become a PreFab to be used.
So how do I work with small simple GameObjects that only needs a UILabel, without a UIPanel being created? And is it possible at all?
If you look at this screenshot:
http://grab.by/zo5Q
"CatapultGameStone" is being spawned about 40 times inside "CatapultGameScene" in an array of "stones" that each contains a value using UILabel. This causes 40 draw calls!
So I just want to add one UIPanel to "CatapultGameScene" and spawn only UILabels on the "CatapultGameStone".
How do I do that?
-
Widgets cannot exist without a managing panel. Think of widgets as meshes, and panels as renderers. You can't see a mesh. You can only see renderers.
-
But they would exist with a Panel, just first when they are actually spawned. Can this not be done? Doesn't this highly affect the modularity of one's workflow, if you cannot separate GameObjects into prefabs as much as you want?
-
You can do it just fine, provided you use NGUITools.AddChild to create it, adding it directly to the panel's hierarchy. If you use Object.Instantiate, you are likely to run into an issue where you'll be modifying a widget before its parent has been set, thus causing it to create a new panel.