Skip to content

Latest commit

Β 

History

86 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Grid Level Editor

A grid-based level editor for Unity, built with UI Toolkit. It lets you author, manage and preview tile-and-block levels stored as ScriptableObjects β€” directly in the editor and at runtime.

Current version: 2.1.0 Β· Unity 2023.2+ Β· UI Toolkit

Watch the demo

Watch on YouTube

Overview

The tool is split into two editor windows and a runtime generator:

  • Block Library β€” define reusable block types (id, icon, prefab, footprint).
  • Level Editor β€” paint levels on a grid using drag-and-drop, with selection, rotation, copy/paste and undo/redo.
  • Runtime Generator β€” spawns the authored level in the scene with staggered DOTween animations and optional auto-switching between levels.

Levels and blocks are plain ScriptableObjects under Assets/Resources/StaticData, so they are versionable and load through the standard static-data pipeline.

Features

Block Library

  • Dedicated window (Tools β†’ Grid Level Editor β†’ Block Window).
  • Create, rename and delete block types; assign id, prefab and an optional icon.
  • Auto icons: when a block has no icon sprite, the editor shows the prefab's auto-generated preview (Unity AssetPreview) everywhere β€” palette, grid, plates and drag ghosts. The icon sprite is just a manual override.
  • Define multi-cell footprints (rectangle, L, T, cross, …) on a paint grid.
  • Search and sort by id, prefab or icon name.
image

Level Editor

  • Visual grid editor (Tools β†’ Grid Level Editor β†’ Level Window).
  • Create, rename, resize and delete levels.
  • Drag blocks from the palette onto the grid; multi-cell objects render as a single merged plate that follows their exact footprint.
  • Range selection, rotation, copy/paste and a per-level undo/redo history.
  • Context menu (right click) for block selection, rotation, copy/paste and clearing.
  • Zoom for large grids (βˆ’ / οΌ‹ / 1:1 buttons or Ctrl + mouse wheel).
  • Free pan: hold the middle mouse button to drag the map anywhere inside a clipped viewport; a βŠ• button recenters it.
  • "No space here" flash when a block or paste can't fit β€” including the blocking multi-cell object's plate.
  • Built-in log panel and a controls overlay.
image image image

Runtime Generator

  • Spawns floor tiles and blocks from the authored level data through injected factories.
  • Staggered show/hide animations via DOTween.
  • One block per object is spawned at the object's geometric center.
  • Optional auto-switching to the next level on a configurable interval.

Controls & Shortcuts

Action Input
Place a block Drag a tile from the palette onto the grid
Move a block / object Left-click drag
Select cells (range) Ctrl + Left-click
Block context menu Right-click
Copy / paste selection Ctrl + C / Ctrl + V
Undo / redo Ctrl + Z / Ctrl + Y (or Ctrl + Shift + Z)
Clear selection Backspace / Delete
Zoom in / out Ctrl + Mouse Wheel (or βˆ’ / οΌ‹ buttons)
Reset zoom 1:1 button
Pan the map Middle-mouse drag
Recenter the map βŠ• button

Undo/redo is window-local and scoped to the current level: the history resets when you switch levels and when the window is closed.

Getting Started

  1. Open the project in Unity 2023.2 or newer.
  2. Open Tools β†’ Grid Level Editor β†’ Block Window and create a few blocks (only the id is required; without an icon sprite the prefab's preview is used).
  3. Open Tools β†’ Grid Level Editor β†’ Level Window, create a level, then drag blocks onto the grid.
  4. Enter Play mode to see the level spawned by the runtime generator.

Data locations:

  • Levels β€” Assets/Resources/StaticData/LevelsData
  • Blocks & library β€” Assets/Resources/StaticData/BlocksData

Project Structure

Path Responsibility
Assets/Code/LevelEditor Runtime data model (LevelMatrixEditor, LevelCell, BlockDataEditor, BlockLibrary, LevelDataDTO)
Assets/Code/LevelEditor/Editor UI Toolkit editor windows, grid view, palette, popups and undo history
Assets/Code/LevelEditor/Editor/Grid Focused grid components (zoom, selection, hit-testing, highlight, plates, cell render, drag/move, pan, palette placement, shortcuts) split out of the grid view
Assets/Code/Infrastructure Runtime generator, factories, static-data and save/load services

The grid is stored as a flat, row-major LevelCell[] (Unity cannot serialize 2D arrays) and addressed through Index(x, y). Multi-cell blocks share a positive InstanceId; standalone cells use 0.

Tech Stack

  • Unity 2023.2
  • UI Toolkit (editor UI)
  • Zenject (dependency injection)
  • DOTween (runtime animation)
  • Odin Inspector (serialization in SaveLoadService)

Changelog

2.1.0

  • Auto block icons: a block's prefab preview is used when no icon sprite is set (icon is now optional).
  • Free middle-mouse panning of the grid inside a clipped viewport, with a βŠ• recenter button.
  • Grid zoom controls (βˆ’ / οΌ‹ / 1:1, Ctrl + mouse wheel) documented.
  • "No space" flash now also blinks the blocking multi-cell object's plate.
  • Internal: the monolithic grid view was refactored into focused single-responsibility components under Editor/Grid.

2.0.0

  • UI Toolkit rewrite (migrated off Odin): drag-and-drop grid editor, multi-cell footprints, range selection, rotation, copy/paste, per-level undo/redo and the runtime generator.

About

Unity Grid Level Editor - A powerful, fully customized level editor made in Unity using Odin Inspector. Built to quickly prototype and manage grid-based levels both in the editor and at runtime.

Topics

Resources

Stars

47 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages