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
.
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
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 |
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