Author Topic: Dynamic content NGUI  (Read 2695 times)

9to9

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Dynamic content NGUI
« 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

LightSky

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 56
    • View Profile
Re: Dynamic content NGUI
« Reply #1 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.

9to9

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Dynamic content NGUI
« Reply #2 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic content NGUI
« Reply #3 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).

9to9

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Dynamic content NGUI
« Reply #4 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