2D Toolkit Forum

2D Toolkit => Support => Topic started by: Goepfie on March 13, 2013, 05:06:24 pm

Title: [BUG] SpriteAnimationEditor Array out of Range
Post by: Goepfie 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.
Title: Re: [BUG] SpriteAnimationEditor Array out of Range
Post by: unikronsoftware on March 13, 2013, 05:53:38 pm
Thank you for reporting this. I'll fix this for the next release.
Title: Re: [BUG] SpriteAnimationEditor Array out of Range
Post by: DannyB 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)
Title: Re: [BUG] SpriteAnimationEditor Array out of Range
Post by: unikronsoftware on April 30, 2013, 09:47:26 pm
That's definitely a bug.
It should not let you delete the only frame.
Title: Re: [BUG] SpriteAnimationEditor Array out of Range
Post by: DannyB on April 30, 2013, 09:53:58 pm
Ok, cool.
Let me know if need more info or reproduction steps/screencast.
Title: Re: [BUG] SpriteAnimationEditor Array out of Range
Post by: unikronsoftware 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)
Title: Re: [BUG] SpriteAnimationEditor Array out of Range
Post by: DannyB on April 30, 2013, 10:03:07 pm
Patched. Thanks.