How to store references of generated objects


In my code I generate a grid of objects with Instantiate but I don’t know how to keep reference of each of them by their coordinates (I rely on int coordinates to keep things simple).
At first I looked at GameObject[,] but for that I need to know the maximum size my “map” would become and I don’t have that information as it is infinite as it’s generated as the player moves. Another limitation I found about GameObject[,] is that I can’t store negative indexes, so I would not be able to use to store x and y values inside it.

What do you suggest me to use?

Thank you.

Take a look at games like Minecraft where the world is made up of fixed “chunks” which are loaded as the player moves.

You’re not going to be able to make a game where objects travel far from the origin as you start to get rounding issues.