Author Topic: IndexOutOfRangeException with NGUI Atlas Maker 3.7.7  (Read 5409 times)

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
IndexOutOfRangeException with NGUI Atlas Maker 3.7.7
« on: January 10, 2015, 01:15:53 AM »
Ran into this bug when making some standard additions and tweaks to my atlas. My atlas has lots of free space on it still.

The exact action that seemed to trigger this was "Add Clamped Border". It seems like I'll need to restore my atlas from an older copy via version control, since the current copy appears to be permanently corrupted. I'll save a copy of the corrupted atlas before restoring it to an older version, in case you need me to email/PM it to you, ArenMook.

It seems to possibly be the same bug as this one from many months ago... http://www.tasharen.com/forum/index.php?topic=9256.0

IndexOutOfRangeException: Array index is out of range.
UIAtlasInspector.AddClampedBorder (.UISpriteData sprite) (at Assets/NGUI/Scripts/Editor/UIAtlasInspector.cs:451)
UIAtlasInspector.OnInspectorGUI () (at Assets/NGUI/Scripts/Editor/UIAtlasInspector.cs:305)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Inspector/InspectorWindow.cs:1093)
UnityEditor.DockArea:OnGUI()
« Last Edit: January 10, 2015, 01:35:47 AM by Wisteso »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: IndexOutOfRangeException with NGUI Atlas Maker 3.7.7
« Reply #1 on: January 10, 2015, 12:58:05 PM »
What was the border value of that sprite?

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Re: IndexOutOfRangeException with NGUI Atlas Maker 3.7.7
« Reply #2 on: January 10, 2015, 02:14:50 PM »
I believe it was zero at the time (since that's what it is now). However, I think it may have had a border (due to forgetting a step in my manual post-processing explained below) (Edit: It did have an impossible border, as a side effect of my manual bleeding issue fix + forgetting to clear border as one of the steps)

I should mention there is one thing I'm doing that might be a bit unusual (but still within reason I think) and possibly related to this bug:

I have a sprite that was intended to be 64x64, but since it is stretched across the whole screen, neighbor pixels (usually transparent) kept bleeding in at the edges (due to linear filtering). So I instead made it 68x68 (using "Add a Clamped Border") and then every time I update the Atlas, I have to re-add the clamped border, and tweak the dimensions for that one sprite.

Those tweak being (under "Dimensions") +1 to X, +1 to Y, and -2 to Width, and -2 to Height. Effectively making it a 64x64 sprite again, but with similar pixels outside that remove the blending issue.

Slightly more off-topic for a moment: I'd love a way to have NGUI do my currently manual process. "Add Clamped Border" is close, but uses "Border" gives the wrong behavior for what I need. I may end up just putting those touchy sprites in a separate atlas for a while, so I dont have to keep re-applying the dimension tweak when adding/updating other sprites.
« Last Edit: January 10, 2015, 02:24:01 PM by Wisteso »

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Re: IndexOutOfRangeException with NGUI Atlas Maker 3.7.7
« Reply #3 on: January 10, 2015, 02:22:02 PM »
Sure enough, I was due to one of my tiny sprites with the bleed issue (width: 2, height: 2) having an impossible border of size 2 for Left/Right/Bottom/Top, and then trying to add a Clamped Border again on top of that. (Since any atlas changes revert my bleeding pixel fix)

Once I set the borders all to zero, and then added the clamped border again, it worked fine.

As for why the borders were set to 2, thats a side effect of adding a Clamped border twice in the past and forgetting to zero the border out (again, because I'm manually adding some bleed pixels around the sprite using a kind of hacky method).