Hello Guest

Author Topic: unable to commit sprite collection because of error  (Read 6480 times)

breeves

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
unable to commit sprite collection because of error
« on: August 29, 2013, 10:54:47 pm »
I have a sprite collection in which I was replacing an image. When I initially replaced the image I accidentally replaced with one that was much too large and immediately got an error telling me that the collection couldn't be committed because it exceeded the atlas size. I swapped it out with a new image but am now getting this error any time I try to commit:
IndexOutOfRangeException: Array index is out of range.
tk2dSpriteCollectionBuilder.Rebuild (.tk2dSpriteCollection gen) (at Assets/ThirdParty/TK2D/Editor/tk2d/Sprites/tk2dSpriteCollectionBuilder.cs:938)
tk2dSpriteCollectionEditorPopup.Commit () (at Assets/ThirdParty/TK2D/Editor/tk2d/Sprites/SpriteCollectionEditor/tk2dSpriteCollectionEditorPopup.cs:447)
tk2dSpriteCollectionEditorPopup.DrawToolbar () (at Assets/ThirdParty/TK2D/Editor/tk2d/Sprites/SpriteCollectionEditor/tk2dSpriteCollectionEditorPopup.cs:437)
tk2dSpriteCollectionEditorPopup.OnGUI () (at Assets/ThirdParty/TK2D/Editor/tk2d/Sprites/SpriteCollectionEditor/tk2dSpriteCollectionEditorPopup.cs:836)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

Any help would be greatly appreciated.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: unable to commit sprite collection because of error
« Reply #1 on: August 30, 2013, 11:38:14 am »
What version of 2D Toollkit are you using?

breeves

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: unable to commit sprite collection because of error
« Reply #2 on: August 30, 2013, 02:45:28 pm »
I'm using 2.1.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: unable to commit sprite collection because of error
« Reply #3 on: August 31, 2013, 12:43:14 pm »
How bizzare, that line still doesn't make any sense at all. Any chance you can set up a simple repro case to look at? Should be easy enough to work out what went wrong that way. If not, I'll add some more debugstuff into the code to try and narrow this down.

breeves

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: unable to commit sprite collection because of error
« Reply #4 on: September 03, 2013, 05:05:51 pm »
It's possible that I'm using a more recent version than 2.1, but that's the one that I have saved off on my back up drive. Is there an easy way to tell which version I have? When I go to the About menu item it just says that it's version 2, final. The loop in which it's breaking is:
Code: [Select]
for (int i = 0; i < atlasData[atlasIndex].entries.Length; ++i)
{
var entry = atlasData[atlasIndex].entries[i];
Texture2D source = textureList[entry.index];
                int spriteId = entry.index;
                tk2dSpriteCollectionDefinition.Pad padMode = gen.textureParams[entry.index].pad;
                Texture2D mask0 = GetMaskTexture(gen, source, 0, spriteId, padMode);
                Texture2D mask1 = GetMaskTexture(gen, source, 1, spriteId, padMode);
                Texture2D mask2 = GetMaskTexture(gen, source, 2, spriteId, padMode);
               
                if (!entry.flipped)
{
for (int y = 0; y < source.height; ++y)
{
for (int x = 0; x < source.width; ++x)
{
tex.SetPixel(entry.x + x, entry.y + y, source.GetPixel(x, y));
                            Color m = new Color(mask0 == null ? 0 : mask0.GetPixel(x, y).r, mask1 == null ? 0 : mask1.GetPixel(x, y).r, mask2 == null ? 0 : mask2.GetPixel(x, y).r);
                            maskTex.SetPixel(entry.x + x, entry.y + y, m);
}
}
}
else
{
for (int y = 0; y < source.height; ++y)
{
for (int x = 0; x < source.width; ++x)
{
tex.SetPixel(entry.x + y, entry.y + x, source.GetPixel(x, y));
                            Color m = new Color(mask0 == null ? 0 : mask0.GetPixel(x, y).r, mask1 == null ? 0 : mask1.GetPixel(x, y).r, mask2 == null ? 0 : mask2.GetPixel(x, y).r);
                            maskTex.SetPixel(entry.x + y, entry.y + x, m);
}
}
}
}

The line on which it's breaking is:
Code: [Select]
tk2dSpriteCollectionDefinition.Pad padMode = gen.textureParams[entry.index].pad;

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: unable to commit sprite collection because of error
« Reply #5 on: September 03, 2013, 06:33:58 pm »
You're probably on an older version if it says 2 final - what version of Unity are you using? The version of unity matters now as there were issues with older versions of tk2d with newer versions of Unity...

Edit: Also it might make it a whole lot easier if you could set up a simple repro case for this. Just the sprite collection + textures would be sufficient, and you can blank out the textures if theres any confidential stuff in there. support at unikronsoftware.com if possible.