Convert Figma logo to code with AI

sabresaurus logoSabreCSG

Level design tools for Unity

1,365
137
1,365
61

Top Related Projects

Procedural generation library for Unity

Quick Overview

SabreCSG is a Unity plugin for creating and editing 3D levels directly within the Unity editor. It provides a set of tools for constructive solid geometry (CSG) operations, allowing developers to quickly prototype and build complex 3D environments using simple shapes and boolean operations.

Pros

  • Intuitive and fast level design workflow within Unity
  • Real-time CSG operations for quick iteration
  • Supports both primitive shapes and custom brushes
  • Integrates seamlessly with Unity's existing tools and workflow

Cons

  • Learning curve for users unfamiliar with CSG concepts
  • Performance can degrade with very complex geometry
  • Limited documentation and community support compared to some alternatives
  • May require additional optimization for final game builds

Code Examples

// Creating a new CSG brush
CSGBrush newBrush = CSGBrush.Create(PrimitiveBrushType.Cube);
newBrush.transform.position = Vector3.zero;
newBrush.transform.localScale = Vector3.one * 2f;
// Performing a boolean subtraction operation
CSGBrush baseBrush = CSGBrush.Create(PrimitiveBrushType.Cube);
CSGBrush cuttingBrush = CSGBrush.Create(PrimitiveBrushType.Sphere);
CSGBooleanOperationsUtility.Subtract(baseBrush, cuttingBrush);
// Applying a material to a CSG brush
CSGBrush brush = CSGBrush.Create(PrimitiveBrushType.Cylinder);
Material newMaterial = Resources.Load<Material>("MyCustomMaterial");
brush.SetMaterial(newMaterial);

Getting Started

  1. Import the SabreCSG package into your Unity project.
  2. In the Unity menu, go to "Window" > "SabreCSG" to open the SabreCSG toolbar.
  3. Select the "Draw Brush" tool and click in the scene view to create a new brush.
  4. Use the CSG tools in the toolbar to manipulate and combine brushes.
  5. When finished, click "Build" in the SabreCSG toolbar to generate the final mesh.

For more detailed instructions and advanced usage, refer to the official SabreCSG documentation and examples provided in the GitHub repository.

Competitor Comparisons

Procedural generation library for Unity

Pros of ProceduralToolkit

  • More comprehensive procedural generation toolkit with a wider range of features
  • Better documentation and examples for easier integration
  • Active development and regular updates

Cons of ProceduralToolkit

  • Steeper learning curve due to its broader scope
  • May include unnecessary features for specific use cases
  • Less focused on CSG operations compared to SabreCSG

Code Comparison

SabreCSG:

CSGBrush brush = new CSGBrush();
brush.SetShape(PrimitiveBrushType.Cube);
brush.Transform.position = new Vector3(0, 0, 0);
brush.Transform.localScale = new Vector3(2, 2, 2);

ProceduralToolkit:

MeshDraft draft = MeshDraft.Cube(Vector3.one);
draft.Move(Vector3.zero);
draft.Scale(Vector3.one * 2);
Mesh mesh = draft.ToMesh();

Both examples create a cube, position it, and scale it. SabreCSG uses a CSG-specific approach, while ProceduralToolkit offers a more general-purpose mesh generation method.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

SabreCSG

SabreCSG is a set of level design tools for building complex levels quickly inside Unity.

Using Constructive Solid Geometry techniques SabreCSG allows you to add and subtract brushes to create great levels without needing to understand 3D art packages.

Introduction Image 1ADD AND SUBTRACT BRUSHES TOGETHER TO MAKE GREAT PLAY SPACES

Boolean brushes allow you to add and subtract arbitrary shapes together to rapidly create walls, rooms or carve out doors and windows. The brushes are used as a template for building the final geometry allowing you unprecedented flexibility for making minor tweaks or big changes simply by modifying the brushes.

POWERFUL BRUSH AND GEOMETRY TOOLS

SabreCSG comes equipped with a whole range of tools for editing brushes and geometry, from intuitive resize tools which let you quickly block out spaces to vertex and edge editing modes which let you go in and tweak in more detail, to advanced clipping tools allowing you to bevel or cut entire brushes in two.

Introduction Image 2
Introduction Image 3APPLY MATERIALS AND EDIT UVs

With its surface tools, SabreCSG allows you to translate, rotate and scale surfaces, apply new materials, exclude faces from the final geometry for speed. And with newly upgraded features there’s a whole set of new helper functions to speed up your workflow.

SabreCSG was originally sold on the Unity Asset Store, but as of 14th October 2016 has been open sourced under the MIT License (see LICENSE for details). It is now maintained on this Github repository.

Core Features:

  • Boolean CSG algorithm supporting partial rebuilding.
  • Draw tools to rapidly create levels by drawing brushes directly.
  • Resize tools allow you to resize spaces intuitively.
  • Vertex tools to refine and add precision details.
  • Change materials or edit UVs with surface tools built for level design.
  • Clip planes allow you to bevel brushes or even split them in two.
  • Export built geometry to .OBJ for use in external 3D tools.
  • Vertex Colors - Apply vertex colors per face which are baked into the built meshes.
  • Experimental Code API - Experimental support for procedurally generating levels through code.

Documentation and videos on how to use SabreCSG are available at the SabreCSG Learn website or the wiki.

Download

Download SabreCSG

Installation Instructions

Documentation

Visit Wiki Pages

Join the Official SabreCSG Discord Server

Donations:

If you love SabreCSG and wish to say thanks then please feel free to make a donation. Your donations are a huge motivator to continue the development of SabreCSG.

paypal