An open API service indexing awesome lists of open source software.

https://github.com/gylansalih/vsc-unity-csharp-custom-snippets

A collection of useful C# snippets for Unity game development. These snippets are designed to speed up the process of writing commonly used methods and structures.
https://github.com/gylansalih/vsc-unity-csharp-custom-snippets

Last synced: 3 months ago
JSON representation

A collection of useful C# snippets for Unity game development. These snippets are designed to speed up the process of writing commonly used methods and structures.

Awesome Lists containing this project

README

        

# VSC Unity CSharp Custom Snippets

A collection of useful C# snippets for Unity game development. These snippets are optimized for use in Visual Studio Code and help you quickly create frequently used methods and structures.

![Example Snippet](https://github.com/GylanSalih/VSC-Unity-CSharp-Custom-Snippets/blob/main/ExampleImg.png)

## Contents

- **Unity Script Template**: A complete template for Unity scripts with essential namespaces and Start/Update methods.
- **Public Start Method**: Template for the `Start` method.
- **Public Update Method**: Template for the `Update` method.
- **Public FixedUpdate Method**: Template for the `FixedUpdate` method.
- **Public Coroutine Method**: Template for coroutines.
- **Public OnCollisionEnter2D Method**: Template for 2D collisions.
- **Public OnTriggerEnter2D Method**: Template for 2D triggers.

## Usage

To use the snippets, follow these steps:

1. In Visual Studio Code, go to **Edit** -> **Preferences** -> **Configure User Snippets**.
2. Select **C#** from the list of languages.
3. Add the snippets to your `csharp.json` file.
4. You can then invoke the snippets by typing the corresponding trigger keywords in your C# code.

## Example

### Unity Script Template

To create a new Unity script, type `unityscript` and press `Enter`. This will insert a pre-defined script with the basic structure.

- **Public Start Method**: Type `pubstart` to generate a public Start method with brackets.
- **Public Update Method**: Type `pubupdate` to generate a public Update method with brackets.
- **Public OnCollisionEnter2D Method**: Type `puboncollision2d` to generate a private OnCollisionEnter2D method with brackets.
- **Public OnTriggerEnter2D Method**: Type `pubontrigger2d` to generate a private OnTriggerEnter2D method with brackets.
- **Public Coroutine Method**: Type `pubcoroutine` to generate a public Coroutine method with brackets.
- **Public FixedUpdate Method**: Type `pubfixedupdate` to generate a public FixedUpdate method with brackets.

## License

This project is licensed under the MIT License.