Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: frarees on November 22, 2012, 04:17:12 PM

Title: Create UI "on-the-fly" (programmatically)
Post by: frarees on November 22, 2012, 04:17:12 PM
Hi,

Is there any way to create a full GUI just from code? Every time I need to create a GUI have to do it with the UI Wizard, and I'd like to know if dynamically generating the UI is possible/factible.

Thanks!
Title: Re: Create UI "on-the-fly" (programmatically)
Post by: JRoch on November 22, 2012, 06:00:35 PM
Of course.  You'd just create gameobjects in a hierarchy and attach the script components in proper sequence.  You can set all of the component variables and settings via code, too.

Caveat:  Aren might correct the statements above if there is some under the hood magic that I'm not aware of.
Title: Re: Create UI "on-the-fly" (programmatically)
Post by: ArenMook on November 22, 2012, 11:00:17 PM
Just look at the code of the UICreateWidgetWizard. All these widgets you're creating via the menu are created programmatically, and the code is available for you to examine, just like the rest of NGUI.
Title: Re: Create UI "on-the-fly" (programmatically)
Post by: Echo on November 23, 2012, 10:41:47 PM
You can also instantiate a prefab containing the GUI to the correct panel. You might need to do some code scaling though.
Title: Re: Create UI "on-the-fly" (programmatically)
Post by: alics on February 06, 2013, 12:27:41 PM
Is there a way to add widgets during runtime using Javascript?

UICreateWidgetWizard is in C#
Title: Re: Create UI "on-the-fly" (programmatically)
Post by: ArenMook on February 06, 2013, 10:15:56 PM
I answered you in the other thread. No need to ask twice.