I have a game where the player is constantly moving, so the world is generated on the fly. Below I have included the function for generating a new chunk, my noise function isnt the slow part, the part that is taking up most of the time is the TileMap.SetTiles() where im passing in the array of tiles. Im wondering if there is a better way to do this, or a way to speed it up.
I prune old chunks since a large tilemap was causing the game to slowdown. I also make the tile arrays in tasks since that part doesnt interact with the UI so that should be fine. the timers say that scheduling and generating the tasks take about 4ms, Pruning chunks takes about 1ms per chunk, it usually is around 4-6ms, setting the chunks is always around 6ms. This means in total when a player hits a trigger to generate more chunks it takes about 16ms. This means its a noticeable stutter since everything else runs fairly smooth. I can tell exactly when a chunk is made especially the longer the level goes on the real worry is i have a pretty decent PC, I have tried building the game and even as a build i still see the stutter so i know its not just editor lag.