Author Topic: Atlas size confusion  (Read 7508 times)

artician

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Atlas size confusion
« on: May 24, 2014, 05:41:48 PM »
Hi,
I'm trying to place a new font into an existing atlas, but when I do so NGUI tells me it's too large to fit.  My atlas is currently 4096^2, and the new font is 1024x512.  As you can see below, almost 75% of the atlas is not in use, so could you perhaps tell me why I'm receiving this error?



Thanks.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Atlas size confusion
« Reply #1 on: May 24, 2014, 06:27:58 PM »
Unless you have a bunch of things hiding in the alpha channel, it sounds like a bug.

If you can do thise consistently, you should make a repro case, so ArenMook can test it out and see what's going wrong. If you make a unitypackage without the actual NGUI in it, you can post here, then I'll take a look too.

artician

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Re: Atlas size confusion
« Reply #2 on: May 24, 2014, 06:30:50 PM »
Yeah I had checked the alpha channel just to be sure.  I'll see about packaging it up and be back.  Thanks for the help.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Atlas size confusion
« Reply #3 on: May 24, 2014, 06:51:39 PM »
As I said in the PM (echoing here for anyone else interested), it worked fine for me in the repro. Not sure what's going on with yours.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas size confusion
« Reply #4 on: May 25, 2014, 05:37:10 PM »
The large font in the bottom left looks like it's 2k by 2k, not 1024x512. 2048x2048, when added to an atlas without any trimming, means it requires a 4k texture to fit, because +1 gets added for padding, making it 2049x2049, thus unable to fit into a single texture.

artician

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Re: Atlas size confusion
« Reply #5 on: May 26, 2014, 12:49:32 PM »
Yes, the large font at the bottom is 2048^2.  I have two fonts in the game.  The second is 1024x512.  There should be more than enough room in that atlas, and it appears there is given Nicki's testing, I just have to figure out why it's complaining on my version.

artician

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Re: Atlas size confusion
« Reply #6 on: May 26, 2014, 12:54:39 PM »
Okay, I just tried removing a sprite from the atlas, and received the same error.

"The selected sprites can't fit into the atlas.
Keep large sprites outside the atlas (use UITexture),
and/or use multiple atlases instead"

artician

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Re: Atlas size confusion
« Reply #7 on: May 26, 2014, 01:09:36 PM »
One more update: I saw something I hadn't before when choosing a font to use for a new Panel:



I've never see this popup define fonts as "Embedded" or not.  If that's always been that way, I've never seen the two at the same time (meaning I probably overlooked it before when it was all "Embedded" or all displaying the font path).

Regardless, if it's using "Embedded" to define what fonts are in the game atlas, that's incorrect, because the "playtime_512" is the 2048^2 size font you can see in the atlas screenshot I provided.

Additionally, for the fonts that display their filepath, there is no such path in my project that begins with "cgui/..."  Even if it's truncated from something else, there is no such path.

Let me know if there's some meta-data somewhere that stores asset filepaths for NGUI.  Hopefully that helps debug the issue or give you guys some ideas for me to try.  I'm trying to move forward in the areas of my project until the original bug is figured out, but NGUI is pretty determined to screw me up it seems.  :(

Thank you as always.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas size confusion
« Reply #8 on: May 26, 2014, 11:39:47 PM »
Embedded is for dynamic fonts that don't have a resource file to load, so I'm not sure what happened in your case to make them show prefabs. I'd delete those and start anew at this point.

When creating a font using the 2k by 2k texture, don't bother putting it into an atlas. Atlases are for small textures. 2k is massive. Simply create a font that uses a texture, not an atlas.

artician

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Re: Atlas size confusion
« Reply #9 on: May 27, 2014, 01:09:41 PM »
I'd still like to solve the bug issue though. 

You know that I ran into the versioning conflict between unity3.x and the latest NGUI release, but I reverted my project to a previous backup package before that happened, so this issue wasn't caused by this.  Because of the versioning conflict my project did change folders (created a new project and opened the backup package in it).  I then updated NGUI 3.6.0b1, probably from the version immediately preceding it.

Other than that, those are the only real changes between this oddness and what was initially a working NGUI toolset.  What can I do to completely eliminate NGUI from my project, reimport it, and still retain the atlases and font connections?  Can you suggest anything else? 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas size confusion
« Reply #10 on: May 28, 2014, 05:36:47 AM »
Follow the 3 step process from the readme file. All references will be kept.

artician

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Re: Atlas size confusion
« Reply #11 on: May 28, 2014, 11:41:45 AM »
I did that upgrading from 3.5.1 to 3.6.0, but I repeated the steps now to be sure, and I am still receiving the error "The selected sprites can't fit into the atlas" when I attempt to remove one.

artician

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Re: Atlas size confusion
« Reply #12 on: May 28, 2014, 12:08:07 PM »
Being kind of fed up with this, I decided to just go ahead and create a new atlas.  I am unable to do that as well.  Creating a new atlas produces this error in the Unity log:

UnityException: Creating asset at path E:/_Projects/gameDev/alphaBlast/gameData/Assets/cAssets/gui/atlas/failAtlas.mat failed.
UIAtlasMaker.OnGUI () (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:893)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)

Please help, this is fundamentally blocking the release of my project.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas size confusion
« Reply #13 on: May 29, 2014, 06:06:15 AM »
Switch to the stand-alone build platform. It will let you keep 4k atlas sizes. After that try the process again. If doesn't work, create a new project, copy your atlas there and try it there. If still doesn't work, then I'm at a loss, and I recommend you create your atlas from scratch.

As for the error message -- it seems to fail to create the atlas. Is your atlas material marked read-only by your file system? Try deleting it first.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Atlas size confusion
« Reply #14 on: May 29, 2014, 11:38:23 AM »
Sounds like it's something from outside blocking file access, or something like that. Maybe a virus scanner locks the file, or the drive is out of room or something silly like that?

Strange to be sure.