Skip to content

A tool that will help you easily create/edit complex 3D scenes inside Unity

License

Notifications You must be signed in to change notification settings

hfjooste/LevelBuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Level Builder for Unity

License

You are free to do whatever you want with this library. You're allowed to use this for commercial projects, edit the source code and even redistribute the source code. No attribution is required (but appreciated)

Requirements

  • Unity 2021.3.5f1 (should work on older versions as well)

Features

This tool allows you to easily create/edit complex levels. It was designed for 3D games, but can also be used to generate 2D levels. There's two methods you can use to generate your levels:

  1. Static: The level is specified in the editor and can't be changed without creating a new scene
  2. Dynamic: A list of all possible levels are specified in the editor. An ID that is linked to each level is then used to generate the correct level. This method can be used to build an entire game using a single scene

There's also two different level types you can use in your game (this is specified for each level and can be mixed in the same game):

  1. Two Dimensional: This is used to generate a 2D or 2.5D level
  2. Three Dimensional: This is used to generate a full 3D level

Creating a new Palette

Palette Example

  1. Right click in the project view
  2. Go to Create > Level Builder > Palette
  3. Add all the items you'll need for your level to this file
    • Name: The name displayed when creating new levels. This is only used to help you identify which tiles you're applying and will not be displayed to the player
    • ID: An ID for this palette item. This is used to load the correct data when editing/generating levels and should be unique for each item in the palette
    • Color: The color used to represent this item when editing levels. This color is not used in the actual level
    • Prefab: The prefab that will be instantiated when generating the level using this palette item
    • Offset: The offset applied to the instance when generating the level using this palette item

Creating a new Level

Level Example

  1. Right click in the project view
  2. Go to Create > Level Builder > Level
  3. Specify the palette you've created in the previous section
  4. Specify the size of the level (Size X and Size Y)
  5. Start designing your level by selecting an item from the dropdown list and clicking on the empty tiles

Generating your level (Static)

Static Level

  1. Add an empty game object to your scene
  2. Add the Static Level Loader component to the new game object
  3. Specify the level that you've created in the previous section
  4. Play the scene and wait for the level to be generated (should be generated instantly)

Generating your level (Dynamic)

Dynamic Level

  1. Add an empty game object to your scene
  2. Add the Dynamic Level Loader component to the new game object
  3. Add the Level Index component to the new game object
  4. Add all the available levels to the Level Index component and specify a unique ID for each level
  5. Play the scene and wait for the level to be generated (should be generated instantly)

Please note: It's currently using PlayerPrefs to load the current level ID. But this can easily be changed

Demo

Demo Level

This library includes an example of a palette, level and scene. You can find this inside the Demo directory:

  • Data: This includes an example of a palette and levels
  • Materials: A few basic materials applied to the prefabs when generating the level
  • Prefabs: A few basic objects that will be instantiated when generating the level
  • Scripts: A basic demo script that allows you to change levels (dynamic only)
  • 3D.unity: A basic scene that loads the specified data and generates the 3D level
  • Static.unity: A basic scene that loads the specified data and generates the 2.5D level
  • Dynamic.unity: A basic scene that contains a list of 2.5D levels and generates the correct level based on the current level index

About

A tool that will help you easily create/edit complex 3D scenes inside Unity

Resources

License

Stars

Watchers

Forks

Languages