Skip to content

kyaulabs/unity-scripttemplates

Unity - ScriptTemplates

https://kyaulabs.com/

Contributor Covenant   Conventional Commits   GitHub   Gitleaks
Semantic Versioning   Discord

Disclaimer

About

The Unity Editor uses ScriptTemplates as the templates for new file creation, all of these can be accessed by right-clicking in the Project window and selecting Create.

Usage

To utilize these templates over the defaults locate the following.

Location: %ProgramFiles%\Unity\Hub\Editor\20xx.x.xxfx\Editor\Data\Resources\ScriptTemplates\

cd %ProgramFiles%\Unity\Hub\Editor\20xx.x.xxfx\Editor\Data\Resources
rm -rf ScriptTemplates
git clone https://github.com/kyaulabs/unity-scripttemplates ScriptTemplates

Format

All templates follow the same naming syntax:

81-C# Script__Enum-NewEnum.cs.txt
81 C# Scripts Enum NewEnum .cs
Menu Position Menu Name Menu Item Default filename File extension

Variables

There are a couple of variables that you are allowed to use inside of script templates.

  • #SCRIPTNAME#: will be replaced with the name of the script
  • #NOTRIM#: will make it so the white-space of the current line is not trimmed
  • #ROOTNAMESPACEBEGIN# and #ROOTNAMESPACEEND#: will wrap something with the default namespace

Attribution