Author Topic: Problems with Atlas-Creation  (Read 6609 times)

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Problems with Atlas-Creation
« on: March 07, 2014, 08:47:49 AM »
Hey there.

Today some weird stuff is going on with the Atlas-Creation.

1. Completely empty Scene. Imported latest NGUI Version.
2. Added some Sprites (.PSD Files) to my Project
3. Opened up the Atlas Maker, selected all the Sprites and hit "Create"
4. Hit on "View Sprites" and got this:



Clearly this is not what I want.

And another thing. Sometimes this isn't even working, the results above are the "best" I could achieve today. Almost 50% of the time the Atlas isn't created and I get an MissingReferenceException regarding "Texture2D":

"MissingReferenceException: The object of type 'Texture2D' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Texture.get_width ()
UIAtlasMaker.PackTextures (UnityEngine.Texture2D tex, System.Collections.Generic.List`1 sprites) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:144)
UIAtlasMaker.UpdateTexture (.UIAtlas atlas, System.Collections.Generic.List`1 sprites) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:531)
UIAtlasMaker.UpdateAtlas (.UIAtlas atlas, System.Collections.Generic.List`1 sprites) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:646)
UIAtlasMaker.UpdateAtlas (System.Collections.Generic.List`1 textures, Boolean keepSprites) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:629)
UIAtlasMaker.OnGUI () (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:976)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
"

I also tried to delete and reimport NGUI, but it didn't help at all :/


EDIT_01:

Just tried this on a completely new and empty Project. Same stuff. It's working with weird results or it doesn't and gives me this error.

UncleAcid

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: Problems with Atlas-Creation
« Reply #1 on: March 07, 2014, 09:11:15 AM »
The Atlas Maker has been very unstable lately. It should work fine if you just try again, In my case I ususally have to do:

1. Open Atlas Maker
2. Select all my textures
3. Click Create
4. It will fail, so i click Replace (usually it works this time, if not try replace again)
5. If Replace doesn't work, try just Add/Update a couple times.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Problems with Atlas-Creation
« Reply #2 on: March 07, 2014, 09:20:29 AM »
Yeah, I also tried that for hours now and it doesn't help at all.
When I the Atlas is created, with the weird looking results, I tried it to Add/Update. Then, AFTER creation it gives me the MissingReferenceException again when I add/update it.

I'm sitting here now for some hours with empty projects and different sprite-graphics, some which are used in production and some I just made for testing purposes -> nothing works.

I'm using the latest Unity version btw. Are there any specific new settings I have to take in mind? The .PSD Files I'm importing are automatically set to "Sprite" as Texture Type with Pixelts to Unit = 100. I guess these values are alright that way?

UncleAcid

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: Problems with Atlas-Creation
« Reply #3 on: March 07, 2014, 09:40:22 AM »
Texture import settings shouldn't matter, a texture is a texture.

I've noticed that the MissingReferenceException issue seems to happen when the sprites need a larger atlas than it currently has (causing it to increase and rebuild), have you tried adding just a couple sprites to see if it shows up ok ?

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Problems with Atlas-Creation
« Reply #4 on: March 07, 2014, 09:45:31 AM »
Yes! I'm trying that right now!

If I'm on big sprite and some small ones it's ok, but at a certain amount of sprites it's starting to look weird :/
And sometimes I'm just stuck in the "Updating"-Progress-Bar and nothing happens and I have to ForceQuit Unity.
This is NOT ok! :(

UncleAcid

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: Problems with Atlas-Creation
« Reply #5 on: March 07, 2014, 10:01:47 AM »
Does Unity actually become unresponsive or can you still do stuff ?

If you get the MissingReferenceException error most of the time the progress bar stays there, but it doesn't actually freeze, and it will go away next time you use the Atlas Maker.

Try changing to using the Custom packer as well, I've noticed that it seems to work better for me in most cases.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Problems with Atlas-Creation
« Reply #6 on: March 07, 2014, 10:08:03 AM »
Unity doesn't freeze, but I can't use the Atlas-Maker. While the Progress-Bar is active and I click for example "View Sprites" in the Atlas-Maker I can't close the View-Sprites-Window anymore.

But I have one question: is this behaviour intended?

Just for testing I created an Atlas with 4 big sprites with these dimensions: 865x627
And for some reason it's creating an atlas with 1024x512.
Shouldn't the created Atlas be...bigger?



As you see, some sprites are squeezed into one "field".

So I looked up the Atlas-Texture:



And changed the "Max Size" Value to 2048. As soon as I did, the Atlas was "updated" immediately and the big sprites looked like they should:



When I add new Sprites to the Atlas and use Add/Update I get another MissingReferenceException, being again stuck in the Updating-Progress-Bar, but there I can click again on Add/Update and by doing so the other sprites are added accordingly and everything looks fine.

Though this "looks" fine this is way to unstable for me and a really bad way of handling the creation of an atlas and updating it!

What bothers me the most right now: is this of the latest Unity Version or NGUI Version? Before updating from NGUI 3.5 to 3.5.3 this didn't happen at all.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with Atlas-Creation
« Reply #7 on: March 07, 2014, 10:30:19 AM »
While the atlas texture gets created with proper dimensions, texture import settings can completely screw up the atlas by shrinking the texture on import. In your case the texture was stuck with the maximum size of 1024x1024, which is the cap when targeting lower-end devices or using the Fastest Quality setting.

Ensuring that your atlas texture doesn't get limited is important for everything to work properly. I don't advise you to limit your textures manually. Check your Quality settings instead.

The missing reference thing with texture being destroyed by Unity for no apparent reason is an issue I'm currently investigating again (for like the 5th time).

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Problems with Atlas-Creation
« Reply #8 on: March 07, 2014, 10:43:20 AM »
Yes, I'm targeting iOS for now. I looked up the Quality-Settings and besides setting iOS from "Simple" to "Fantastic" and using "Full Res" I couldn't find anything else which limits the Texture Size.

Tried it again: same behaviour as before. When I select everything I need the Atlas-Maker limits the Atlas to 1024x512.
(4096x4096 is selected btw.)

I also tried to set all the imported Sprites to a bigger size like 2048 or 4096 (override for iPhone is selected!) and then to create the atlas. Doesn't help at all.

I tried that with setting the imported Sprites as "Sprites" and also as "Advances Textures". Always the same stuff :/

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with Atlas-Creation
« Reply #9 on: March 07, 2014, 10:50:20 AM »
How are you not getting an early exit error is what I'd like to know. I have code in there that prevents the atlas from being created if the texture gets shrunk by Unity. Hrrm...

Also... why is your "Tester" texture set to 16 bit? It must be RGBA 32 bit.

Edit: You seem to have the texture type set to "Sprite", when it should be "Advanced". The texture import settings are wrong... Turn off the "2D" mode.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Problems with Atlas-Creation
« Reply #10 on: March 07, 2014, 11:05:45 AM »
Uh, I don't know why I don't get this error :/

And I don't know why the Texture is set to 16 bit. This happens automatically when the Atlas-Texture is created, it also sets it to "Sprite" automatically. How do I turn the 2D Mode off?

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Problems with Atlas-Creation
« Reply #11 on: March 07, 2014, 11:09:07 AM »
Ah, found it! Yeah, that did the job. God...this is so...dumb :/

Anyway, thanks so much for the help! This bothered me the whole day, uff...