Author Topic: [SOLVED] Random failures when regenerating atlas using internal packer (3.0.0e)  (Read 5776 times)

yuriks

  • Guest
(I'm using NGUI 3.0.0e and Unity 3.5.7f6.)

If I elect to use the internal sprite packer instead of Unity's one, I frequently get these two errors in the log when trying to update an existing atlas with new sprites:

Error: Unsupported image format - the texture needs to be ARGB32 or RGB24
UnityEngine.Texture2D:EncodeToPNG()
UIAtlasMaker:UpdateTexture(UIAtlas, List`1) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:485)
UIAtlasMaker:UpdateAtlas(UIAtlas, List`1) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:574)
UIAtlasMaker:AddOrUpdate(UIAtlas, Texture2D) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:531)
UIFontMaker:OnGUI() (at Assets/NGUI/Scripts/Editor/UIFontMaker.cs:275)
UnityEditor.DockArea:OnGUI()

Error: NullReferenceException: Object reference not set to an instance of an object
System.IO.File.WriteAllBytes (System.String path, System.Byte[] bytes)
UIAtlasMaker.UpdateTexture (.UIAtlas atlas, System.Collections.Generic.List`1 sprites) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:486)
UIAtlasMaker.UpdateAtlas (.UIAtlas atlas, System.Collections.Generic.List`1 sprites) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:574)
UIAtlasMaker.AddOrUpdate (.UIAtlas atlas, UnityEngine.Texture2D tex) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:531)
UIFontMaker.OnGUI () (at Assets/NGUI/Scripts/Editor/UIFontMaker.cs:275)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)

The atlas image then gets replaced with an empty asset. I'm not modifying the atlas texture import options, they're at the NGUI defaults. If I delete the texture and generate it again it works fine.
« Last Edit: September 26, 2013, 04:10:52 PM by yuriks »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Random failures when regenerating atlas using internal packer (3.0.0e)
« Reply #1 on: September 26, 2013, 03:26:32 PM »
Curious. Replace line 480 in the UIAtlasMaker -- it uses RGBA32. Change it to ARGB32.

yuriks

  • Guest
Re: Random failures when regenerating atlas using internal packer (3.0.0e)
« Reply #2 on: September 26, 2013, 03:52:25 PM »
On my copy of the file 480 is a closing brace. Line 474 is:
  1. tex = new Texture2D(1, 1, TextureFormat.ARGB32, false);
That is, it's already ARGB. Didn't find any references to RGBA32 on the file.

This is how the import settings look like on the failed file:

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Random failures when regenerating atlas using internal packer (3.0.0e)
« Reply #3 on: September 26, 2013, 03:55:33 PM »
Sorry I meant NGUIEditorTools.cs.

yuriks

  • Guest
Re: Random failures when regenerating atlas using internal packer (3.0.0e)
« Reply #4 on: September 26, 2013, 04:01:12 PM »
Changed, same results.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Random failures when regenerating atlas using internal packer (3.0.0e)
« Reply #5 on: September 26, 2013, 04:06:29 PM »
Find the other RGBA32 in that file and change it as well.

yuriks

  • Guest
Re: Random failures when regenerating atlas using internal packer (3.0.0e)
« Reply #6 on: September 26, 2013, 04:10:38 PM »
That one seems to have fixed it, I can update the atlases without any issues now. Cheers for the quick responses!