Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: 9to9 on May 07, 2014, 04:37:03 AM

Title: Dynamic content NGUI
Post by: 9to9 on May 07, 2014, 04:37:03 AM
Hello there,
Anyone have example how to build NGUI from code? i want to make a dynamic GUI based on response that i receive from server, can anyone give me example?what i must do first? is UIRoot created first or what? thx u

Regards, Ama
Title: Re: Dynamic content NGUI
Post by: LightSky on May 07, 2014, 03:28:11 PM
What are you planning on receiving from the server?  If you plan on only having one UI then you should create a UIRoot in the editor and keep a reference to that in your code. 
As you receive details about your UI you could just use NGUI.AddChild to create more objects, as you progress through it you should be keeping track of which object is what so it will be easier to parse through.
Title: Re: Dynamic content NGUI
Post by: 9to9 on May 09, 2014, 05:27:33 AM
What are you planning on receiving from the server?  If you plan on only having one UI then you should create a UIRoot in the editor and keep a reference to that in your code. 
As you receive details about your UI you could just use NGUI.AddChild to create more objects, as you progress through it you should be keeping track of which object is what so it will be easier to parse through.

Ok bro, i dont undestand u saying hahahahaha, so i create UIRoot at hierarchy and i set reference to it in my code and i use NGUI.AddChild ? can u give me example code for NGUI.AddChild, is this code directly add widget/child inside UIRoot?
Title: Re: Dynamic content NGUI
Post by: ArenMook on May 09, 2014, 06:11:20 AM
  1. GameObject copy = NGUITools.AddChild(parent, prefab);
It doesn't add it under UIRoot. It adds it wherever you choose (the 'parent' parameter).
Title: Re: Dynamic content NGUI
Post by: 9to9 on May 12, 2014, 03:21:43 AM
  1. GameObject copy = NGUITools.AddChild(parent, prefab);
It doesn't add it under UIRoot. It adds it wherever you choose (the 'parent' parameter).

Yihaa, thx u bro, thx u :D, u should put code example in NGUI, so rest of us can know how to use it via code only