Hello Guest

Author Topic: [BUG] SpriteAnimationEditor Array out of Range  (Read 6579 times)

Goepfie

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
[BUG] SpriteAnimationEditor Array out of Range
« on: March 13, 2013, 05:06:24 pm »
Hey,

I found another bug, but not sure if its already known. Using  a Multiatlas platform specific sprite collection and single atlas collection. When I create a Clip and (for example) autofill the first 5 frames from the multiatlas collection and then change to another Collection with less sprites in it(I know this is not best practice, but was done for performance testing) the animation editor crashes and becomes inaccessible. The Error seems to be the spriteID not being reset. Debug Console points towards:

tk2dEditor.SpriteAnimationEditor.ClipEditor.DrawPreview() in line 218.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: [BUG] SpriteAnimationEditor Array out of Range
« Reply #1 on: March 13, 2013, 05:53:38 pm »
Thank you for reporting this. I'll fix this for the next release.

DannyB

  • 2D Toolkit
  • Hero Member
  • *
  • Posts: 609
    • View Profile
    • Chicks Ahead
Re: [BUG] SpriteAnimationEditor Array out of Range
« Reply #2 on: April 30, 2013, 09:11:23 pm »
Not sure it is the same bug, or similar, but I thought I would add here instead of a new thread:

1. Not using multi platform
2. Creating a new animation collection, then adding a new clip
3. Then, deleting the very first and only frame (from the timeline, pressing DEL)

I then get out of range error, and have nothing to do other than close it, and reopen.

The error:

Code: [Select]
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[tk2dEditor.SpriteAnimationEditor.ClipEditor+FrameGroup].get_Item (Int32 index)
tk2dEditor.SpriteAnimationEditor.AnimOperatorUtil.NewFrameGroup (System.Collections.Generic.List`1 frameGroups, Int32 selectedFrameGroup) (at Assets/TK2DROOT/tk2d/Editor/Sprites/SpriteAnimationEditor/tk2dSpriteAnimationAnimOp.cs:48)
tk2dEditor.SpriteAnimationEditor.TimelineEditor.DrawFrameGroups (Int32 controlId, Rect frameGroupRect, .tk2dSpriteAnimationClip clip, System.Collections.Generic.List`1 frameGroups, Single clipTimeMarker) (at Assets/TK2DROOT/tk2d/Editor/Sprites/SpriteAnimationEditor/tk2dSpriteAnimationClipTimelineEditor.cs:230)
tk2dEditor.SpriteAnimationEditor.TimelineEditor.Draw (Int32 windowWidth, .tk2dSpriteAnimationClip clip, System.Collections.Generic.List`1 frameGroups, Single clipTimeMarker) (at Assets/TK2DROOT/tk2d/Editor/Sprites/SpriteAnimationEditor/tk2dSpriteAnimationClipTimelineEditor.cs:158)
tk2dEditor.SpriteAnimationEditor.ClipEditor.Draw (Int32 windowWidth) (at Assets/TK2DROOT/tk2d/Editor/Sprites/SpriteAnimationEditor/tk2dSpriteAnimationClipEditor.cs:564)
tk2dSpriteAnimationEditorPopup.OnGUI () (at Assets/TK2DROOT/tk2d/Editor/Sprites/SpriteAnimationEditor/tk2dSpriteAnimationEditorPopup.cs:480)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: [BUG] SpriteAnimationEditor Array out of Range
« Reply #3 on: April 30, 2013, 09:47:26 pm »
That's definitely a bug.
It should not let you delete the only frame.

DannyB

  • 2D Toolkit
  • Hero Member
  • *
  • Posts: 609
    • View Profile
    • Chicks Ahead
Re: [BUG] SpriteAnimationEditor Array out of Range
« Reply #4 on: April 30, 2013, 09:53:58 pm »
Ok, cool.
Let me know if need more info or reproduction steps/screencast.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: [BUG] SpriteAnimationEditor Array out of Range
« Reply #5 on: April 30, 2013, 09:57:35 pm »
That's OK. I managed to reproduce it easily enough.
You can fix it in your version by adding a tiny bit of code in tk2dSpriteAnimationClipTimelineEditor.cs -

Code: [Select]
if (state.selectedFrame != -1 && (GUIUtility.hotControl == controlId || (GUIUtility.keyboardControl == 0 && state.type == State.Type.None)))
{
if (ev.type == EventType.KeyDown && (ev.keyCode == KeyCode.Delete || ev.keyCode == KeyCode.Backspace))

to

Code: [Select]
if (state.selectedFrame != -1 && (GUIUtility.hotControl == controlId || (GUIUtility.keyboardControl == 0 && state.type == State.Type.None)))
{
if (ev.type == EventType.KeyDown && (ev.keyCode == KeyCode.Delete || ev.keyCode == KeyCode.Backspace) && frameGroups.Count > 1)

DannyB

  • 2D Toolkit
  • Hero Member
  • *
  • Posts: 609
    • View Profile
    • Chicks Ahead
Re: [BUG] SpriteAnimationEditor Array out of Range
« Reply #6 on: April 30, 2013, 10:03:07 pm »
Patched. Thanks.