From 729b3dc196dcb58f4c2f675bf8baa3cc0c43fb52 Mon Sep 17 00:00:00 2001 From: stallratte <48615771+stallratte@users.noreply.github.com> Date: Sun, 19 May 2024 03:19:29 +0200 Subject: [PATCH] Fix for issue 799. Last uid is now also read. (#800) --- .../Assets/Tiled/Runtime/TiledMapLoader.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Nez.Portable/Assets/Tiled/Runtime/TiledMapLoader.cs b/Nez.Portable/Assets/Tiled/Runtime/TiledMapLoader.cs index ed811a75a..ac650ff37 100644 --- a/Nez.Portable/Assets/Tiled/Runtime/TiledMapLoader.cs +++ b/Nez.Portable/Assets/Tiled/Runtime/TiledMapLoader.cs @@ -354,21 +354,28 @@ public static TmxLayer LoadTmxLayer(this TmxLayer layer, TmxMap map, XElement xL else if (encoding == "csv") { var csvData = xData.Value; - int k = 0; - - int startIndex = 0; + var k = 0; + var startIndex = 0; + uint gid; + for (var i = 0; i < csvData.Length; i++) { if (csvData[i] == ',') { - var gid = ParseString(csvData, startIndex, i - startIndex); + gid = ParseString(csvData, startIndex, i - startIndex); AddTile(layer, map, gid); - layer.Grid[k++] = gid; + layer.Grid[k++] = gid; startIndex = i + 1; } } + + // Add remaining uid + gid = ParseString(csvData, startIndex, csvData.Length - 1 - startIndex); + + AddTile(layer, map, gid); + layer.Grid[k] = gid; } else if (encoding == null) {