Nerd For Tech
Published in

Nerd For Tech

Unity Script Templates in Visual Studio

Objective: Change Visual Studio’s Unity script templates.

When we create a new script in Unity, Visual Studio creates this by default:

Now that’s great for new programmers. But we’ve been doing this long enough that we don’t need a reminder that the Start method is called at the…start. Here’s how we’ll change that.

We’ll have to navigate to the location on our system where Unity keeps its templates. This may take some poking around. We’ll have to do this for the version of Unity we intend to use — each version we’ve installed will have its own templates. Mine were located at (my Unity version is in boldface):

C:\Program Files\Unity\Hub\Editor\2019.4.28f1\Editor\Data\Resources\ScriptTemplates

Now open the file named 81-C# Script-NewBehaviourScript.cs.txt. It will look like this:

We can edit this to our preferences. We could get rid of the comments. Or maybe we always find ourselves deleting Start and Update until we need them — go ahead and delete them! We can always use auto-complete to add them on a case-by-case basis. Want to always show the Awake method? Add it!

Here are the changes I made:

And it worked!

NOTE: We may have to modify the permissions of the .txt files to save them. In Windows, right click the file and select Properties. On the Security tab, select Users, click Edit, and check the Full control box. We might need administrator permissions to do this! Once we’re done editing the template, we may want to put the Users permissions back to just Read & execute and Read for future security.

--

--

--

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Recommended from Medium

Migrating to Microservices and Event-Sourcing: the Dos and Dont’s

A Byte of Coding Issue #91

Pi Protocol Weekly Updates — Week 6

Watch: Exploring Binary Trees (Part 2) — Braata 1 — Haskell

Creating a Rails Projects with Postgres

Windows Sucks. The Solution is Free.

Ecosystem Grants Update: February 2021

Block Coding: Truth & Misconceptions

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ryan Sweigart

Ryan Sweigart

An independent Unity Developer.

More from Medium

Creating a Physics Based Character Controller from Scratch in Unity

Raspberry Pi and Embedded Linux Adventure (PART1: How to Start)

A low-poly knight 3D model!

Convert Shapefiles to GeoJSON in C#