Building procedural 2D rooms usually means writing the generator, then hand-wiring every wall corner to the right sprite. 2D Map Generator does both. Pick a fill algorithm, link a Tile Set Profile, and the level appears in your Scene view with walls matched to the surrounding floor layout.
🎲 Three Generation Modes
- Random Walk with configurable walker direction, spawn and removal chances
- Rooms + Corridors with non-overlapping rooms joined by L-shaped corridors
- Cellular Automata with smoothing passes and automatic region connection
- The inspector shows only the settings for the active mode
⚡ Live Preview
- Regenerates in the Scene view as you change settings, seeds, prefabs or profiles
- Preview objects are not saved into your scene file
- Clears on entering Play Mode and rebuilds when you return
- Stops at 10,000 cells and keeps the last valid preview
🧱 Automatic Wall Placement
- Walls surround every floor, including diagonal-only corners
- Each wall stores an eight-neighbor floor mask
- Isolated single walls are converted to floor
- Falls back from exact mask to canonical mask to cardinal mask to directional sprite to Generic Wall
🎨 Tile Set Profile
- A ScriptableObject that stores sprite assignments for Base Wall, Floor, Generic Wall, Wall Up/Down/Left/Right and Wall Topology
- Several sprites per role are chosen at random
- Your template prefabs keep their hierarchy, colliders and sorting
- Editing the profile refreshes every linked generator
🔧 Tile Set Builder Window
- Open from Tools > 2D Map Generator > Tile Set Builder
- Import existing sliced sprites by dropping textures or sprites
- Visual 3x3 topology board with filter by mask, hex or direction (N, SE, NW)
- Floors tab with a gallery and a preview panel
- Sprite palette with a role drop-down per sprite
- Undo support on assignments
🎯 Exact Tile Sizing
- Sprite Render Size is set in world units
- Compensates for renderer scale
- Independent of texture Pixels Per Unit
- Prefab transforms and colliders are not changed
📂 Optional Grid Slicing and Prefab Baking
- Slice an atlas by cell size, offset, spacing and PPU
- Bake one prefab per assigned sprite into a dedicated folder
- Apply baked arrays to a LevelGenerator with Undo
🔒 Safety Limits
- Validates grid size, probabilities, room settings and prefab arrays before generating
- Clear console errors instead of silent failures
- Iteration and work caps prevent runaway generation
🌱 Fixed Seeds
- Reproduce the same layout on demand
- The previous random state is restored afterwards, so other systems are unaffected