Author Topic: Helpful, But Not Needed - UIAtlas Tip.  (Read 4420 times)

disturbing

  • Guest
Helpful, But Not Needed - UIAtlas Tip.
« on: July 19, 2012, 03:22:58 PM »
Hey -

I was running into the worse memory issues recently and it took us a few moments to realize how it happened.

We use to have everything set to UIAtlas type 'Normal', but recently switched over to UIAtlas Type to Reference.

When doing this, we have a nice system to switch from HD / SD as mentioned in a tutorial video.

BUT! The original references to the HD setup we made in the Type 'Normal' still persisted, therefore loading HD + SD in when we used SD textures... 'ouch'.

It would be awesome if there was some automatic way to take out those references when switching types and saving the asset.  Otherwise, it would just be awesome to mention this in the documentation / examples / etc to 'Make sure to clean up!'

No hard feelings if nothing comes of this, just something to stick on the web for anyone who runs into memory issues and may have done what I did.

~DisTurBinG

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Helpful, But Not Needed - UIAtlas Tip.
« Reply #1 on: July 19, 2012, 05:01:54 PM »
Set the reference atlas to point to nothing prior to doing a build.

disturbing

  • Guest
Re: Helpful, But Not Needed - UIAtlas Tip.
« Reply #2 on: July 19, 2012, 05:37:16 PM »
Hey,

We are doing it a bit differently.

We want the reference sent prior to building.  We have these references set with a tool so that all the dependencies would only include the SD or HD format..

We have ~25 atlas' and you can imagine how big those are - even compressed.

We are really pushing to have < 20mb builds for mobile, and to do that, we don't want unused textures in an HD or SD build.

Solution: Made a tool to set the reference prior to building.  Works great!

The problem I was mentioning is that When you go from Normal -> Reference, it keeps normal cached and the material reference is still there.  But when you go from Reference - > Normal, it removes the Reference cache in the inspector.

So more or less, there was hidden inspector cache - which comes to my next problem that just occurred.

--

My prefabs are pointing to an UIAtlas which has a reference to HD or SD.  Originally it was HD.

If you click on the 'atlas' in the prefab, it takes you over to the UIAtlas with the reference and all looks great.

But when you check dependencies on this prefab, it has both the HD and SD textures / materials.

I looked all over the place in the prefab (which is small) and for sure there are 0 direct references to the HD or SD textures, other than through the Atlas REF which is currently pointing to SD.

So I then took the 'Sprite' and changed it to some random value then back to the original.  I then applied the Prefab ( to save it ) and checked the dependencies.   The HD ref is now gone.

So it seems maybe the image preview or something internally was caching this HD preview, which in return was building both HD + SD textures.

I hope that makes sense, it's a bit confusing.

~DisTurBinG

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Helpful, But Not Needed - UIAtlas Tip.
« Reply #3 on: July 19, 2012, 06:00:56 PM »
Why are you switching from normal to reference?

You should be creating ALL your UI using the Reference atlas, and the Reference atlas should be completely empty. It should point to another atlas (that's the whole point of the system).

To re-iterate: your "SD" atlas should also be a different atlas that the Reference atlas points to.

disturbing

  • Guest
Re: Helpful, But Not Needed - UIAtlas Tip.
« Reply #4 on: July 19, 2012, 06:11:33 PM »
We use to have everything set to UIAtlas type 'Normal', but recently switched over to UIAtlas Type to Reference.

This was just a transition from doing normal (all hd) to going to a reference.

Originally we just had all normal / hd textures until we wanted to go with the reference solution.  We did not want to start all over by resetting the entire UI to a new UIAtlas, because there are hundreds of elements.  So, we naturally changed them from normal to reference and set it up appropriately, so the existing UI currently pointing to it will handle the SD / HD changes.

Of course people will naturally start off with 'reference type' and not have this issue.  But some people may run into a transition like I did, and not realize that the Normal dropdown still caches old material references, even though you changed it.

That's why.

I suppose since I used your system in a non-standard way, to have prebuild references vs post-built, this won't be an issue for people following the tutorial or starting off with 'reference' and not transitioning.

~DisTurBinG

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Helpful, But Not Needed - UIAtlas Tip.
« Reply #5 on: July 19, 2012, 08:43:39 PM »
Just copy/paste the atlas prefab object in windows explorer (or finder if you use the mac), creating a copy of it. This copy will have all the data of the original, letting you delete the data inside the original.

theprojectabot

  • Guest
Re: Helpful, But Not Needed - UIAtlas Tip.
« Reply #6 on: May 05, 2013, 06:01:21 PM »
I know this is an old thread but I am having this EXACT same problem. Its making things pretty bad.

I have prefabs that I built earlier with a normal atlas at ultra def resolutions.  I then switched over to using a reference atlas option.  However since you can not save(prefab) Ref atlases as reference atlases without them having something that they are referencing I now reference SD.  However when I start the scene UD and HD textures are loaded.  I can see this using Unity 4.1 memory profiler in detail view.  THis happens both in the editor and on the devices.

Its as if the prefab has this texture info serialized into the prefab and it does not get swapped out when I switch atlases for the reference atlas reference.

I have looked at the prefab in a text editor and cant seem to see the connection to these UD prefabs...

Do you have any thoughts ArenMook? or Disturbing?