Default Script Template

When you create a new script, Unity uses a text file to specify its initial layout. That text file is located in your Unity installation folder:

  • Windows: C:\Program Files\Unity\Editor\Data\Resources\ScriptTemplates
  • Mac: /Applications/Unity/Unity.app/Contents/Resources/ScriptTemplates

These paths may differ if you are using Unity Hub or chose a different path when installing Unity.

The template for a new C# Script is 81-C# Script-NewBehaviourScript.cs.txt.

If you make changes to any of the templates, you should keep a copy of your changed file somewhere else so that you do not lose it if you uninstall Unity and can easily apply it when you install a new version of Unity.

It is recommended that you remove the default Start and Update methods because they have a performance cost just for existing, even if they are empty. Adding them back in when you actually need them only takes a few seconds and this helps encourage you to keep your scripts clean. At the very least, you should remove their comments which are absolutely useless to the extent that lazy people who leave them in often do not even bother changing them when they rename the method, meaning the comments become worse than useless because they are not even correct about what the method does anymore.

Any other modifications are up to you. The template used by Kybernetik looks like this:

using UnityEngine;

#ROOTNAMESPACEBEGIN#
public class #SCRIPTNAME# : MonoBehaviour
{
    /************************************************************************************************************************/

    /************************************************************************************************************************/
}
#ROOTNAMESPACEEND#

Note that the /**** is actually on the line immediately after the { and indented, it just looks like there's an extra line between due to word wrapping on this page.

Why only using UnityEngine;?

Visual Studio (and other IDEs) can automatically list types that contain a given sub-string, including ones in namespaces that do not yet have using statements in the current file and will automatically add such statements if necessary. This means the only using statement we need in a script by default is UnityEngine for the MonoBehaviour class.

Why /*************...?

  • These are Comment Separators which help to improve code readability as explained by the Coding Standard.