Skip to content

About

Script Templates for my Unity Projects.

Resources

Stars

19 stars

Watchers

2 watching

Forks

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity Script Templates

This repository is a bundle of the Script Templates I use in my Unity Projets.

Updated for Unity 6000+.


⚠️ Even if this package is still maintained, I worked on the Asset Template package from Sideways Experiments, which allow the use of templates for scripts, text files or even serializanle assets by just using the right name, prefix or suffix to a file to create.

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.


Setup Script templates in Unity

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

Now, 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 !

Create asset menu example

Obviously, you can create your own script templates, or simply adapt these ones for your own use.

Script Templates naming

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

Script Template content

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.

About

Script Templates for my Unity Projects.

Resources

Stars

19 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors