Change the default script template?

Is it possible to change the default template that unity uses to create a script?
Thanks

5 Answers

5

Sure you can ;)

Just go into your Unity-installation-folder and navigate to "/Editor/Data/Resources/". There you will find all templates.

  • NewBehaviourScript.cs
  • NewBehaviourScript.js
  • NewBehaviourScript.boo
  • NewShader.shader

And even `UnityObject.Source.js` and `UnityObject.js` that are used in the webplayer's html page.

How do I find the installation folder? I'm using a Mac. I tried looking through the package contents, I even did a search of my whole computer, and I couldn't find it.

Ehmm, i don't have a mac so i can't tell you where the default installation folder should be. Unity itself is in the "/Editor/" folder. I guess you have some kind of shortcut to start Unity? Just check where it goes. Maybe a mac user can give you more information.

On the Mac they are in the Resources folder inside the app package. The full path is /Applications/Unity/Unity.app/Contents/Resources, hit Command-Shift-G, paste this path and hit Open. This should get you into the folder (if you haven't renamed the Unity folder).

It works, but it won't let me save. Gives me an error. I'm using Monodevelop, but not the Unity version of it, so that might be it.

That's probably a permission issue. Either use a text editor that properly asks for admin permissions when needed (e.g. TextMate does this) or try copying the file to the desktop, edit it there and then copy it back.

As of Unity 3.4, they are now located here (Mac):

/Applications/Unity/Unity.app/Contents/Resources/ScriptTemplates/

Same for Unity 4.0/4.1

For Unity 4.3 on PC it is

C/E/F:/Program Files (x86)/Unity/Editor/Data/Resources/ScriptTemplates

  1. Create Assets/ScriptTemplates to override built-in templates on a per-project basis.
  2. Reopen the project

This actually works! Unity won't put the default files there, so you've got to copy the ones you want to override from the folders mentioned above.

If anyone is using the new Linux editor and wondering where these templates are located, you can find them in the following directory:

/opt/Unity/Editor/Data/Resources/ScriptTemplates

You’ll probably need to go root to modify them, but it works!