Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

[WIP] NGUI Theme Manager

Discussion in 'Assets and Asset Store' started by Ziboo, Jan 14, 2014.

  1. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    Hi All,

    I would like to present my last script in WIP.

    NGUI is a very good GUI library, but the thing that made me struggle for sometime is that, if you want to change a color for instance, you have to go through all your scenes assets of prefabs and modify it.

    So I made a Theme Manager, it allow you to create a theme, and tell which controls have to be themable, you can then control your interface from one place, and even switch theme at runtime if you want.

    The usage is simple, you have a ThemeManager, that store a Theme, in a theme you create Styles (Color, Label Effect,...) and last you add a ThemableScript to the NguiControl you want to customize and check which styles you want to apply for each properties. Simple !


    Tell me what you think ?
    Do you think it's usefull ?
    What would you like to see in the future ?


    Features:

    • Simple to use, custom editor inspectors
    • Runtime theme swapping
    • Undo Redo editor support

    Interface
    $interface01.jpg

    Styles (For now)
    $styles02.jpg

    Themable Widgets (For now)
    $controls.jpg

    Demo: https://dl.dropboxusercontent.com/u/12070966/NguiThemeDemo/NguiThemeDemo.html


    The Demo use this simple theme swapping script

    Code (csharp):
    1. public class ChangeThemeRuntime : MonoBehaviour{
    2.         public UITheme theme01;
    3.         public UITheme theme02;
    4.  
    5.  
    6.         public void ApplyTheme01 ()
    7.         {
    8.                 UIThemeManager.Instance.theme = theme01;
    9.                 UIThemeManager.Instance.ApplyTheme ();
    10.         }
    11.        
    12.         public void ApplyTheme02 ()
    13.         {
    14.                 UIThemeManager.Instance.theme = theme02;
    15.                 UIThemeManager.Instance.ApplyTheme ();
    16.         }
    17. }
    18.  
    19.  
    20. [FONT=arial][/FONT]

     
    Last edited: Jan 14, 2014
  2. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    Nobody ?
     
  3. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    This looks pretty good! Can themes be created at runtime and assigned to dynamic widgets (also created at runtime) as well?
     
  4. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    Hi, I didn't try actually because I didn't really see a point to do it at runtime, maybe for assigned to dynamic widgets, but the creation of a theme in runtime seams to me useless .

    What you had in mind ?
    What situation it could be usefull ?