Selective array loading

Okay, that subject was pretty random but it kinda describes what I’m looking for…
Anyways. I am trying to make a game world system that is structured in an array.
(these are arrays but I present them this way for ease of visualization):

I00I01I02I03I04I05I

I10I11I12I13I14I15I

I20I21I22I23I24I25I

I30I31I32I33I34I35I

I40I41I42I43I44I45I

I50I51I52I53I54I55I

Every cell in this array presents one screen in the game world. You could think of them as rooms. Each of them then contains their own arrays to present the tilemaps in these rooms.

But here is where the problem comes in. Of course I cannot render all those screen at the same time, that would be just overkill. So my solution is to only load the screens around myself (my current screen is the green one, the adjacent ones that will be loaded are the red ones):

I00I01I02I03I04I05I

I10I11I12I13I14I15I

I20I21I22I23I24I25I

I30I31I32I33I34I35I

I40I41I42I43I44I45I

I50I51I52I53I54I55I

Now the problem is: How do I load and unload the screens around me dynamically? I can’t think of any mechanics related to loading this stuff, and even more problems are caused by the fact that I should dynamically unload and load them as I move. of course it would be good if the new edges would load in the background. The new maps also have to be offset around my current map…
If anyone can help, I’d appreciate it. It might help to know that the “room” size is always the same.

Thanks in advance!

You can use Application.LoadLevelAdditive to load adjacent rooms. Removing them can’t be done in a super straightforward way, because objects don’t maintain any links to the scene from which they were loaded. What you’d have to do is put a script on every object in each scene that identifies which room it is part of. Ideally they would all register themselves with a static list, and then you could simply iterate through the list and call Destroy() on all of them.

You see, the rooms are merely arrays that are loaded and then generated into instanced tiles through a script.

In that case, you just have to use Instantiate() and Destroy() as you add and remove rooms.

so can I make a prefab out of an array then?

You make prefabs out of GameObjects and their children. You probably want to make a prefab of each tile, and use Instantiate to create a room from a set of tiles. At the top level, you need to create your arrays. Although you could record them in a single object in the scene, I recommend you load them from a text file in order to make editing easier.

Ookkies, thanks for all the help so far. Now to figure out how to handle the screen movement…