{"record":{"id":"ec295f6df9aefd6b","repo":"egametang/ET","slug":"tile-already-exists","errorCode":null,"errorMessage":"Tile already exists","messagePattern":"Tile already exists","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.recast/Scripts/Core/Share/Detour/DtNavMesh.cs","lineNumber":466,"sourceCode":"        /// reference it had previously used. In this case the #long's for the\n        /// tile will be restored to the same values they were before the tile was\n        /// removed.\n        ///\n        /// The nav mesh assumes exclusive access to the data passed and will make\n        /// changes to the dynamic portion of the data. For that reason the data\n        /// should not be reused in other nav meshes until the tile has been successfully\n        /// removed from this nav mesh.\n        ///\n        /// @see dtCreateNavMeshData, #removeTile\n        public long AddTile(DtMeshData data, int flags, long lastRef)\n        {\n            // Make sure the data is in right format.\n            DtMeshHeader header = data.header;\n\n            // Make sure the location is free.\n            if (GetTileAt(header.x, header.y, header.layer) != null)\n            {\n                throw new Exception(\"Tile already exists\");\n            }\n\n            // Allocate a tile.\n            DtMeshTile tile = null;\n            if (lastRef == 0)\n            {\n                // Make sure we could allocate a tile.\n                if (0 == availableTiles.Count)\n                {\n                    throw new Exception(\"Could not allocate a tile\");\n                }\n\n                tile = availableTiles.First?.Value;\n                availableTiles.RemoveFirst();\n                m_tileCount++;\n            }\n            else\n            {","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.recast/Scripts/Core/Share/Detour/DtNavMesh.cs#L448-L484","documentation":"DtNavMesh.AddTile checks that no tile currently occupies the target (x,y,layer) location via GetTileAt before inserting. If one is already there, adding again would create overlapping geometry and ambiguous lookups, so it refuses. This is a logical duplicate, independent of tile-slot capacity.","triggerScenarios":"Calling AddTile for a location already loaded; re-adding a tile after a failed/unclean removal; streaming that loads the same (x,y,layer) twice; layered tiles reusing a layer index that is still present.","commonSituations":"Reload without prior remove; double-load from two streaming sources; layer index collision in multi-layer setups; additive scene loading that overlaps existing tiles.","solutions":["Remove the existing tile at (x,y,layer) before adding (call RemoveTile on the prior ref).","Guard with GetTileAt(x,y,layer) == null before AddTile.","Track loaded tile locations in a set to avoid duplicate load requests."],"exampleFix":"// before\nmesh.AddTile(data, flags, lastRef);\n\n// after\nif (mesh.GetTileAt(data.header.x, data.header.y, data.header.layer) != null)\n    mesh.RemoveTile(mesh.GetTileRefAt(data.header.x, data.header.y, data.header.layer));\nmesh.AddTile(data, flags, lastRef);","handlingStrategy":"validation","validationCode":"if (mesh.GetTileAt(data.header.x, data.header.y, data.header.layer) != null)\n    throw new InvalidOperationException(\n        $\"tile already loaded at ({data.header.x},{data.header.y},{data.header.layer})\");\nmesh.AddTile(data, flags, lastRef);","typeGuard":null,"tryCatchPattern":"try { return mesh.AddTile(data, flags, lastRef); }\ncatch (Exception e) when (e.Message == \"Tile already exists\")\n{ /* remove existing then retry, or skip as duplicate */ }","preventionTips":["Remove the tile at (x,y,layer) before re-adding.","Guard AddTile with GetTileAt == null.","Track loaded locations in a set to avoid duplicate loads."],"tags":["validation","detour-navmesh","api-misuse"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}