AdamsLair/duality

IndexOutOfRangeException thrown if Tileset is switched on painted Tilemap

開放

#763 建立於 2019年11月7日

 (3 則留言) (0 個反應) (0 位負責人)C# (287 個分叉)auto 404
BugGood First IssueHelp WantedTilemaps

倉庫指標

星標
 (1,425 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Summary

An IndexOutOfRange exception is thrown if the selected Tilemap's Tileset is switched. This exception only occurs if the Tileset has been painted on with Tiles that have a higher index than the new Tileset's maximum index. I also noticed that sometimes the tile pallette is not updated with the new Tileset.

How to reproduce

  • Create two Tilesets, one with more tiles than the other
  • Create a Tilemap with the larger Tileset
  • Paint on the Tilemap with the highest index Tile in the Tileset
  • Set the Tilemap's Tileset to the smaller one by dragging it into the Tileset section of the Tilemap in the object inspector
  • Try painting on the earlier painted tile

Workaround

  • Don't switch the Tileset on a Tilemap that has already been painted on (this is probably a rare case anyway)
  • If you want to switch the Tileset but don't care about the painted tiles, Set them all to the zero index tile (top left corner) before switching the Tileset

Analysis

  • Exception is thrown at Tile.cs:291 when in the UpdateAutoTileCon method
  • Problem seems to be that the Tilemap has tiles with invalid indexes on them
  • Maybe there needs to be a check for these invalid tiles before executing any paint action on them to reset them to normal

貢獻者指南