At OATH Studios, we understand the importance of efficiency and consistency in game development. Whether you're new to Unity or an experienced developer, reducing repetitive tasks can save hours and improve the quality of your projects. One simple but powerful tool for this is Visual Studio Code User Snippets.
What Are User Snippets?
User Snippets are customizable code templates that automatically insert predefined blocks of code into your files. In VS Code, you can create snippets for C#, which is especially useful for Unity development. This allows you to instantly generate your most common structures, such as default MonoBehaviour scripts, without manually writing boilerplate code.
Benefits of User Snippets
- Eliminate repetitive typing.
- Standardize code structure and formatting.
- Create consistent boilerplate for Unity scripts.
- Speed up workflow by typing a short prefix instead of the full code.
For instance, you can define a snippet that generates your preferred MonoBehaviour class layout by typing mono + Tab, rather than relying on Unity’s default script generator.
How to Create a Unity MonoBehaviour Snippet
- Open VS Code.
- Go to File → Preferences → Configure User Snippets.
- Select CSharp.
- Add the following JSON snippet to the file:
{
"Unity MonoBehaviour Class": {
"prefix": "monobehaviour",
"body": [
"using UnityEngine;",
"",
"public class ${1:NewBehaviourScript} : MonoBehaviour",
"{",
" void Start()",
" {",
" ",
" }",
"",
" void Update()",
" {",
" ",
" }",
"}"
],
"description": "Creates a new Unity MonoBehaviour class"
}
}
Now, typing monobehaviour in VS Code and pressing Tab will automatically expand to your predefined template.
Understanding the Tab Stop
${1:NewBehaviourScript}
1→ Tab stop index; determines the order the cursor jumps when pressing Tab.NewBehaviourScript→ Default text at that position, editable by the user.
Once created, pressing Tab cycles through all placeholders, making it easy to fill in class names and variable names.
Why We Use Snippets at OATH Studios
We rely on snippets for MVC templates, UI utility scripts, and other frequently used components. By keeping these snippets in source control, we ensure our development environment is consistent across all devices, saving time and reducing errors.
Implementing VS Code User Snippets is a best practice for Unity game development, allowing developers to focus more on creating engaging gameplay rather than repetitive coding tasks.

