/unity3d-zoning

Functionality for drawing zones such as rooms on a grid in Unity 3D. Sample project included.

Primary LanguageC#

Area Designation / Zoning in Unity3D

About

This project shows a method of designating unique zones in a Unity3D project, such as rooms. It was inspired by games such as Prison Architect, where the player designates areas in the in game map for different tasks.

This approach uses a union find data structure to group areas that make contact with each other. Each distinct area is uniquely identifiable (shown in the sample project by a unique colour), and points can be tested to see which (if any) area they are contained by.

Features include

  • Drawing zones
  • Deleting zones
  • Preventing overlap of zones
  • Zone touch/overlap detection based purely on position (no pesky colliders or physics required)
  • Preventing zones being treated as touching when only their corners are contacting each other
  • Counting total area filled by zones
  • Counting distinct zones

Resources

Screenshots