Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: artfabrique on October 27, 2015, 07:26:28 AM

Title: Extending NGUI inspectors.
Post by: artfabrique on October 27, 2015, 07:26:28 AM
Good day, sir!
What is the best aproach to writing custom additional editor fields for NGUI widgets?
Our game is very "interfaces-heavy" and it is very hard to maintain styles across the whole project.
We want to create something like styles selector&editor for different NGUI objects. For example text size/color/fx. Sprites size/solor etc.
Like presets.
Title: Re: Extending NGUI inspectors.
Post by: ArenMook on October 29, 2015, 07:23:08 AM
If I was doing it... I'd approach it by attaching a custom script to each widget that's marked as [ExecuteInEditMode]. Inside this script I would have a field that specified what type of a color this widget should be affected by, such as "foreground", "background", "text", etc. I would then set the widget's color in the Update() function after checking to see if the color is actually changing (otherwise the scene will constantly be marked as edited).

I would also add a Start() function that will destroy the script if the application is playing, so that it's not there at run-time.