This repository is a bundle of the Script Templates I use in my Unity Projets.
Updated for Unity 6000+.
That package is open source and free to use in any projects, and is a way better approach than copy-pasting templates from a Unity version's install folder to another.
Are called "script templates" the source of the content generated by Unity when you create a new C# Script for examples.
They are written in your Unity install folder, in Editor/Data/Resources/ScriptTemplates. You can notice a specific file naming, see below for more informations about it.
To setup my custom Unity script tempates, download or clone this repo into your Unity install folder. If your Unity editor is open when you set these files, close it and reopen it.
git clone https://github.com/hubertgdev/unity-script-templatesNow, if you try to create a new asset (by right-clicking in the Project view, or from Assets > Create menu), you can see some new menus for script creation !
Obviously, you can create your own script templates, or simply adapt these ones for your own use.
You can see that all the template scripts files have a specific naming syntax :
1-Scripting__MonoBehaviour Script-NewMonoBehaviourScript.cs.txt
| 1 | Scripting | MonoBehaviour Script | NewMonoBehaviourScript | .cs |
|---|---|---|---|---|
| Menu position | Menu name | Submenu name | Default name of the new created file | Created file extension |
Note that submenus are facultative, but you can setup as many submenus as you want, by separating elements with "__".
You can make script templates of any text asset you want (it can be C#, JSON, XML, YAML, TXT, or any code or text content).
Inside these scripts, you can also use #SCRIPTNAME# keyword. When Unity generates the new asset, it will replace that keyword by the created file name. It can be useful for automating class name generation.
