Skip to content

Commit

Permalink
fix: Removed an unnessesary error when fetching a tileset tile that h…
Browse files Browse the repository at this point in the history
…as a higher id than the size of the tileset tile list
  • Loading branch information
Cammin committed May 21, 2024
1 parent 11e8350 commit 1672803
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Assets/LDtkUnity/Editor/Builders/LDtkBuilderTileset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,18 @@ public void BuildTileset(TileInstance[] tiles)

LDtkProfiler.BeginSample("CacheNeededTilesArtifacts");
TileBase[] tileAssets = new TileBase[tilesLength];
List<LDtkTilesetTile> artifactTiles = artifacts._tiles;
int artifactCount = artifactTiles.Count;
for (int i = 0; i < tilesLength; i++)
{
int t = _tiles[i].T;
try

//if the tile is ever higher than the number of artifacts,
//it means the tileset definition was reshaped and some rogue tiles were left behind in the level,
//awaiting to be recovered upon bringing back the tileset def size.
if (t < artifactCount)
{
tileAssets[i] = artifacts._tiles[t];
}
catch (Exception e)
{
Importer.Logger.LogError($"Failed to load a tile artifact at id \"{t}\" from \"{tilesetDef.Identifier}\". It's possible that the tileset definition file has imported improperly.\nLevel: {Level.Identifier}, Layer: {Layer.Identifier}\n{e}");
tileAssets[i] = artifactTiles[t];
}
}
LDtkProfiler.EndSample();
Expand Down

0 comments on commit 1672803

Please sign in to comment.