question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IndexOutOfRangeException in TileMap grid

See original GitHub issue

I’ve got an IndexOutOfRangeException by painting some tiles:

[Edit] Error:   An error occurred: IndexOutOfRangeException: Index was outside the bounds of the array.
CallStack:
   at Duality.Grid`1.get_Item(Int32 x, Int32 y) in c:\projects\duality\Duality\Utility\Grid.cs:line 91
   at Duality.Editor.Plugins.Tilemaps.CamViewStates.FillTilemapTool.FloodFillTiles(Grid`1& fillBuffer, Grid`1 tiles, Point2 pos, Int32 maxTileCount, Point2& fillAreaTopLeft, Point2& fillAreaSize) in c:\projects\duality\DualityEditorPlugins\Tilemaps\CamViewStates\TilemapTools\FillTilemapTool.cs:line 167
   at Duality.Editor.Plugins.Tilemaps.CamViewStates.FillTilemapTool.GetFloodFillArea(Tilemap tilemap, Point2 pos, Boolean preview, Grid`1 floodFillArea, Point2& floodFillOrigin) in c:\projects\duality\DualityEditorPlugins\Tilemaps\CamViewStates\TilemapTools\FillTilemapTool.cs:line 128
   at Duality.Editor.Plugins.Tilemaps.CamViewStates.FillTilemapTool.UpdatePreview() in c:\projects\duality\DualityEditorPlugins\Tilemaps\CamViewStates\TilemapTools\FillTilemapTool.cs:line 71
   at Duality.Editor.Plugins.Tilemaps.CamViewStates.TilemapEditorCamViewState.UpdateActiveState() in c:\projects\duality\DualityEditorPlugins\Tilemaps\CamViewStates\TilemapEditorCamViewState.cs:line 379
   at Duality.Editor.Plugins.Tilemaps.CamViewStates.TilemapEditorCamViewState.OnMouseMove(MouseEventArgs e) in c:\projects\duality\DualityEditorPlugins\Tilemaps\CamViewStates\TilemapEditorCamViewState.cs:line 645
   at Duality.Editor.Plugins.CamView.CamViewStates.CamViewState.OnMouseMove() in c:\projects\duality\DualityEditorPlugins\CamView\CamViewStates\CamViewState.cs:line 617
   at Duality.Editor.Plugins.CamView.CamViewStates.CamViewState.RenderableControl_MouseLeave(Object sender, EventArgs e) in c:\projects\duality\DualityEditorPlugins\CamView\CamViewStates\CamViewState.cs:line 873
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnMouseLeave(EventArgs e)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ilexpcommented, Aug 14, 2016

Got it! The bug wasn’t actually related to the repro steps, but occured when click-dragging the fill tool across a tilemap border, i.e. starting an operation on a valid tile and holding the mouse button while moving the cursor so it would hover a tile out of range.

Fixed, binary package update on its way. Should be available in about 10 minutes.

0reactions
ilexpcommented, Aug 13, 2016

I think an message-dialoge would be nice. Its going to pop up when you didn’t save your work and ask you, if you want to apply your changes.

I checked on this again, and the message dialog actually does pop up - but only when you attempt to close the Tileset editor or deselect the Tileset. As long as you keep it open and don’t select a different Resource, you won’t get the dialog.

Experimented with showing it when tabbing the editor away in addition to closing it, but that turned out to be too annoying to make it the regular behavior. Tabbing away an active editor is something that does happen in regular workflows a lot - without necessarily meaning that the previous operation needs to be applied.

End result: I’m going to leave the dialog behavior as is for now.

I could reproduce this bug by doing this:

  1. Import spritesheet into the project view
  2. create a spritesheet from the imported pixmap -> set tile size (16x16)
  3. open tile editor -> set tile size (16x16) for the tileset (main texture)
  4. “setup tilemap layers” -> single layer
  5. selected a empty tile from the tile palette and filled the whole map with this empty tile (color bucket)

I just realized that I forgot to hit that “Apply”-Button in the Tileset-Editor… So thats seems to be bring on the bug.

I can’t reproduce the bug here using the steps and regardless of whether or not I hit Apply. Are you reproducing the bug in a new, empty project? Can you go into more detail what exactly you’re doing, i.e. “what buttons you’re pressing in which order”? Also, can you upload the .png file of the tileset you’re using?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[2D] Multiple errors thrown continuously on resizing the grid ...
When Tilemap Grid size is changed from Inspector then it causes the editor to throw IndexOutOfRangeException, GUI Error, OverflowException ...
Read more >
Question - Tilemap LockPosition Only?
IndexOutOfRangeException: Index was outside the bounds of the array. UnityEditor.Tilemaps.HandlePositionRotationBrush.BoxFill (UnityEngine.
Read more >
IndexOutOfRangeException thrown if Tileset is switched on ...
An IndexOutOfRange exception is thrown if the selected Tilemap's Tileset is switched. This exception only occurs if the Tileset has been painted ...
Read more >
[Bug] IndexOutOfRangeException when zooming in/out on ...
With v1.4.2, when zooming in/out on the Zoomable Map example, there are continuous errors with the following call stack.
Read more >
Why is my tilemap smaller than my grid? how do I fix this?
It basically sets how big each pixel is in regards to editor scale. The tile map has the same value on it too....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found