How do you customize script templates in Unity?

← Unity answers

Copy a template from the editor's ScriptTemplates folder into Assets/ScriptTemplates in your project, edit it, and Unity uses your version for new scripts.

Unity builds the Assets > Create menu from template files. A template is a text file with placeholders that are replaced when a script is created.

  • Find the originals in the Unity installation: Editor/Data/Resources/ScriptTemplates (on macOS, inside the app bundle under Contents/Resources/ScriptTemplates).
  • Copy the one you want, for example 81-C# Script-NewBehaviourScript.cs.txt, into Assets/ScriptTemplates.
  • The file name controls the menu: a priority number, the menu name, then the default file name and extension.
  • Reopen the project or reimport if the menu does not update.
using UnityEngine;
 
public class #SCRIPTNAME# : MonoBehaviour
{
    void Start()
    {
        #NOTRIM#
    }
 
    void Update()
    {
        #NOTRIM#
    }
}

#SCRIPTNAME# becomes the file name without extension, and #NOTRIM# keeps empty lines from being removed. A template stored in the project is shared with the team through version control.

Related questions

Start debugging smarter today

Try Bugsee for free — no commitments, no hidden fees.

Free sign upLive demoNo credit card required