This is a highly opinionated boilerplate suitable for quick-and-dirty game development and game jams. This way, you can just simply make your game without having to implement tedious but necessary systems. I created this template taking my experiences from my two previous game jams ggj15-loli and ggj16-wayang. Currently I don't include any game-specific libraries or codes, but this might change in the future.
While it is possible to use this template for game production, I'd advise against it; the template is designed to be easy to code and design, trading performance for simplicity. However, feel free to take parts of this template for your game or modify it to suit your purposes.
I write the template on Unity 5.3. I also avoided certain codes and constructs to ensure that this template works on HTML5 and PC. I don't have time to test it, but the template should work on most other platforms with some work (for example, you might have to create your own input system on mobile phones).
How to use
Simply clone the repository or download it, then open the folder with Unity.
.gitignoreand meta files settings for git (from
SceneControllerthat contains various public methods that can be targeted by
PauseControllerthat provides a simple mechanism to pause the game without needing to use the dreaded technique
Time.timeScale = 0.
- Automatically generate tag and layer const generation, inspired from Randyanto/CherryTree and others.
.gitignore and settings for git
The only necessary folders are
Assets (which contains, well, assets) and
ProjectSettings (which contains various Unity project configurations). Everything else is not necessary and will be generated by Unity (most are Unity and C# compiler caches, as well as Visual Studio project files and solutions).
I also make
.meta files in assets are visible and assets are serialized as text instead of binary (under Edit > Project Settings > Editor).
PauseController provides several mechanisms for your game objects to be notified when the game needs to be paused. This way, you do not have to set
Time.timeScale = 0 (which would cause problems with custom UI elements that use
Update()). You can also get away from having to build a state machine just for pausing the game.
UnityEvent, that can be configured to fire when the application lose focus or manually through
Automatically disable and enable all listedTurns out that there are issues with
Behaviour, including several Unity components that are not
Resume()methods (such as
Type.GetType(), I'll take another look later.
PauseListenerto hook from game objects (needed for dynamically instantiated objects).
GameStateController provides several mechanisms for your game objects to be notified when the state changes. It can be seen as a more generic version of
UnityEvent, that will fire when the state is changed.
GameStateListenerto hook from game objects (needed for dynamically instantiated objects).
Automatic tag and layer constants generation
Important to avoid runtime errors, as well as slightly improve performance since we use constants. The script is available at I'll add this later; I want a solution that triggers automatically, while Randyanto/CherryTree apparently still needs user trigger.
Editor/ConstGenerator.cs, inspired by Randyanto/CherryTree, this, and this.
Since Unity 5.3, you do not need constants for scenes;
SceneManager accepts scene names.
- Change "Default Behavior Mode" at Edit > Project Settings > Editor to "3D" if you want to create 3D game. There are some differences between 2D and 3D mode regarding default scene view and lighting configurations.
- Coding conventions follow the [C# Coding Guidelines][Csharp_Coding_Guidelines].
Feel free to read the source codes for various other caveats and notes regarding the scripts.Nah, will add documentation and unit tests later.
- Automatically disable and enable behaviours in
- Add automatic tag and layer constants generation
- Add documentations and unit tests
- Add necessary libraries