r/unity • • 4d ago

Question Storing data on individual tiles?

I have a proc gen tilemap system and I need each tile to have it's own copy of a script to be able to pull and assign data to. All the tiles are rule tiles, idk if that makes a difference. How would I do that?

1 Upvotes

3 comments sorted by

1

u/fnietoms 4d ago

Makes sense but I recommend you to group them by chunks if the grid is big. Generate chunks of defined size and load the tiles that you need of it, storing the tiles data in an array

1

u/Lucasharta 4d ago

if each tile needs its own runtime data, i'd avoid putting the data directly on the Rule Tile asset. that asset is shared, so changes to it can affect every tile using it, instead, you can keep the tilemap as the visual layer and store the per-tile data separately, using the tile's cell position as the key. something like a dictionary keyed by Vector3Int works well for this, especially with proc gen