Tilemap Save/Load System Update for Cozy City Builder

April 19, 2025

Hello, again!

You may have noticed that I have a purpose to share with you the portfolio works I have been doing on the site I have opened for a while. I am sharing with you the first update of my city building simulation game that I have made and whose structure will (maybe) change in the future. Here, contrary to what you think, I have published an editor update that I have realized on Unity and that I can use later, rather than the basic systems that will be in the development phase of the game. This editor update will make it easier for me to create the structure of the maps I will use in the game in the future.

Understanding the New Tilemap Save/Load System: A User-Friendly Overview

In the latest update to our Cozy City Builder prototype, we’ve introduced a robust system for saving and loading custom tilemaps, making it easier than ever for players to preserve and revisit their unique city layouts. Imagine you’ve spent hours designing the perfect city block, carefully placing roads, buildings, and decorations. With the new system, you can now save your creation with a custom name, and later reload it exactly as you left it—even after closing and reopening the game. This is possible thanks to a new set of scripts that manage not only the tiles themselves but also the objects placed on them, the map’s shape, and other important details like the date of your last save.

The process is straightforward for users: when you want to save your map, you simply provide a name, and the system takes care of storing all the necessary information in a dedicated save file. Loading a map is just as easy—select your saved map from a list, and the system will reconstruct your city, placing every tile and object back in its original position. The system also supports different map shapes (like rectangles, O’s, T’s, and more), and remembers the thickness of borders or special features you’ve chosen. All of this is managed through a user-friendly interface in the Unity Editor, where you can view, create, overwrite, or delete saves with just a few clicks. The update ensures that your creative work is never lost and that you can experiment freely, knowing you can always return to a previous version of your city.

Technical Deep Dive: Strategies and Implementation in the Tilemap Save/Load Architecture

From a technical perspective, the new save/load system is built around several key strategies to ensure reliability, flexibility, and maintainability. At its core, the system uses a serializable data container called SaveData, which encapsulates all relevant information about the current tilemap state. This includes a list of TileData objects (each representing a single tile and any object placed on it), map dimensions, shape, border thickness, versioning information, and metadata like save descriptions and timestamps. By serializing this data into JSON files, the system achieves both human-readability and compatibility with Unity’s built-in serialization tools.

The architecture is divided into clear responsibilities: the TilemapSaveManager handles all file operations, user interactions, and save metadata management, while the TilemapGenerator is responsible for the actual creation, destruction, and placement of tiles and objects in the scene. This separation follows the Single Responsibility Principle, making the codebase easier to maintain and extend. When saving, the manager collects all current tile and object data, serializes it, and writes it to a uniquely named file in a dedicated directory. When loading, it reads the file, deserializes the data, and instructs the generator to reconstruct the map according to the saved parameters. Special care is taken to support different map shapes and border thicknesses, with logic to ensure that only valid tiles are created and that objects are placed precisely where they belong.

A notable strategy is the use of versioning and metadata within the save files, allowing for future compatibility and easier debugging. The system also avoids Unity’s tag-based object identification, instead relying on name patterns and component checks to determine object types, which increases flexibility and reduces coupling. The editor scripts provide a rich interface for managing saves, including validation, confirmation dialogs, and real-time feedback, all designed to streamline the workflow for both developers and players. Overall, the update leverages best practices in serialization, modular design, and user experience to deliver a powerful and extensible tilemap save/load solution.

To see the code, you can check out the GitHub repository.

View Project on GitHub