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)
- Unity 2021.3.5f1 (should work on older versions as well)
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:
- Static: The level is specified in the editor and can't be changed without creating a new scene
- 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):
- Two Dimensional: This is used to generate a 2D or 2.5D level
- Three Dimensional: This is used to generate a full 3D level
- Right click in the project view
- Go to Create > Level Builder > Palette
- 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
- Right click in the project view
- Go to Create > Level Builder > Level
- Specify the palette you've created in the previous section
- Specify the size of the level (Size X and Size Y)
- Start designing your level by selecting an item from the dropdown list and clicking on the empty tiles
- Add an empty game object to your scene
- Add the Static Level Loader component to the new game object
- Specify the level that you've created in the previous section
- Play the scene and wait for the level to be generated (should be generated instantly)
- Add an empty game object to your scene
- Add the Dynamic Level Loader component to the new game object
- Add the Level Index component to the new game object
- Add all the available levels to the Level Index component and specify a unique ID for each level
- 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
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