Search Unity

Switching Interface Look 'n Feel

Discussion in 'UGUI & TextMesh Pro' started by launchpad, Aug 26, 2014.

  1. launchpad

    launchpad

    Joined:
    Aug 17, 2007
    Posts:
    95
    Ok, just preliminary findings, and probably really bad form, but:

    Case: I have a common interface (module) in which I want to change the look and feel, depending on application in which it is intergrated. I would love to just swap atlases, but can't do it with the Unity runtime atlases.

    Solution (preliminary - works in very simple case images and spriteSwap transition buttons):
    Using the resources folder (may work elsewhere), make a main sprites folder that is the source of all sprites for the uGUI elements. Assign to each element.

    Make a copies of main in the resources folder. Each will become a source for interface variation. Includes a copy of the original main as a variation. Each variation contains complete copies of all sprite elements with identical names to those in main.

    So my resources folder contained Main, SpritesBlue, Sprites Red. Main started off being a copy of SpritesBlue. I sprited an image and a spriteswap transition button with different states to test. Ran Unity and showed blue image and button

    Shut down Unity with saved project.

    In file manager, deleted Main in resources, copied and renamed Sprites Red folder to Main. Ran Unity and it now showed red image and buttons instead of blue. Closed Unity, deleted main, copied and renamed Blue to main and ran Unity, showed blue button and image.

    Again, no doubt really bad form, and certainly ensure you don't lose the meta files and make sure to save so that library gets updated, but does work in practice (though I did upset Unity a couple of times). I will wait for comment from Tim or Rune just how dangerous this is. If not, I get easy version control over my interface, after all I have to make the alternate sprites anyway and only those in Main get used and mapped to the atlas?
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    So we will be adding workflows for this in the future (asset bundle based). Until that time you can write some custom components that choose and switch sprites / images ect based on some rules that you establish.

    The way I would do it is add a MB to an image that has an 'OnEnable' that changes the sprite that is used for rendering for example, and unloads the 'base' sprite.

    The workflow you have described here, while it will work, seems really brittle and dangerous.
     
  3. launchpad

    launchpad

    Joined:
    Aug 17, 2007
    Posts:
    95
    Yes, felt this way to me too.

    MB stands for?

    Thanks
     
  4. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    MonoBehaviour
     
  5. launchpad

    launchpad

    Joined:
    Aug 17, 2007
    Posts:
    95