What to do with "unloaded" gameObjects?

I’m working on a small 2D project that has a character moving around in a grid of tiles in a top-down fashion. I’m using chunks to reduce the processing load because it freezes a lot when generating large worlds and it worked; I have set up those chunks (GameObjects with tiles as children) with their data about held tiles (GameObjects with a Sprite Renderer and attached script) and they are managed in Lists by a world manager. I understand how to load the chunks near the player and all, but my question is:

When my character is somewhere in the game, and he has chunks loaded, what do I programmatically do with chunks that shouldn’t be loaded anymore, for example the player moves away? They get removed my List of active chunks but where should I let them “go” to “unload” them.

I was thinking of disabling the GameObject of that chunk, and re-enabling it when the player is near but other than that I have no idea. My goal here is to optimize performance and unload unused chunks with their data for my to be large game world.

Maybe I’m missing something very important here but I just can’t seem to wrap my head around a way of doing this.

It sounds like you’re on the right track. What you are describing is almost exactly the same as pooling objects. There are a lot of posts, blogs, videos about it all over the interwebs :slight_smile:

With object pooling, you create an initial amount of objects and use those throughout your game without having to create/destroy (load/unload) them all the time. Instead, you set the values of the objects whenever they are enabled or disabled.

Here is a non-descriptive but visual example of some dude who did something like this:
http://jessefreeman.com/dev-diary/tile-map-editor-object-pooling/
Note the bottom GIF, where you see the tiles on the left get “disabled” and “enabled” on the right.