Author Topic: UIAtlas dummies , resolution support and memory...  (Read 4385 times)

triggly_glix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
UIAtlas dummies , resolution support and memory...
« on: October 16, 2013, 04:23:17 AM »
HI folks,
So I'm about to embark on getting our app sorted for different resolutions. I've read in a few places that NGUI recommends that I use dummy atlases and the .replacement field to point to the real atlas that I want the sprites to be displayed from.
So I just wondered if anybody could help me get this totally clear before I start on it.

So should the process basically be:

I've got an atlas at each resolution that I want to support and also a dummy atlas. This dummy atlas should contain all the same sprites as the real ones but presumably at a very low resolution so that it doesn't use much memory(?)
Then in the editor i assign my sprites from the dummy atlas.

At load time - I unload the .png files for the atlases i'm not using - and load the .png files for the onese that I am - using Resources.Load() ...
possibly then reassigning that png file to the atlas material (at that resolution.)

and then use the .replacement in the dummy atlas to point to the one i have in memory...

that it?
Thanks!



webjema

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UIAtlas dummies , resolution support and memory...
« Reply #1 on: October 16, 2013, 11:02:04 AM »
Hi.
Look at "RetinaPro" plugin for Atlases switching.

The Reference atlas has only link to real atlas (no lo-res sprites).
Everythins else is correct.

triggly_glix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: UIAtlas dummies , resolution support and memory...
« Reply #2 on: October 17, 2013, 02:37:06 AM »
Thanks -
I guess what I don't understand in that case - if the dummy atlas has no sprites in it - then how can I set everything up in the editor? I mean - presumably any sprites in my editory are going to have their Atlas set to the dummy - but if that has no sprites in it - how can I choose their sprite.
Or can I somehow set the .replacement value of the atlas in the editor - like before the game runs...? 

triggly_glix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: UIAtlas dummies , resolution support and memory...
« Reply #3 on: October 17, 2013, 02:54:04 AM »
Yes -
actually got that to work -
so like this basically -

[ExecuteInEditMode]
public class SetupAtlasResolutions : MonoBehaviour
{
   
   public GameObject dummyAtlas;
   public GameObject replaceWith;
   
   // Use this for initialization
   void Start ()
   {
      UIAtlas uiatlasDummy = (UIAtlas)dummyAtlas.GetComponent(typeof(UIAtlas));
      UIAtlas uiatlasReplacemet = (UIAtlas)replaceWith.GetComponent(typeof(UIAtlas));

      uiatlasDummy.replacement = uiatlasReplacemet;
   }
}

and then you can use the dummy atlas in the editor and select sprites from the replacement - cool :)

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UIAtlas dummies , resolution support and memory...
« Reply #4 on: October 17, 2013, 04:00:01 AM »
Since you use a reference atlas, it references an actual atlas when you're setting stuff up - reference the one that fits the resolution you're working on in the editor.

When you're about to build, you clear the reference in the reference atlas, and then you set the reference run time when your UI starts up.