How do I change the default monoDev C# file?

I’ve actually been through this once before. Back in 3.5 I had edited the default C# template file within unity to remove the comments describing the Start and Update methods. I get really tired of erasing those every single time I make a new script. However I noticed that anytime I updated unity it would overwrite the file. I also noticed that file does not appear to be the temple file that monodev itself is calling. So my question is how the hell do I change this?

I can’t believe that the lions share of the entire unity development community erases those 2 lines every time they open a new file?

In unity 4, the template files are located in:

C:\Program Files (x86)\Unity\Editor\Data\Resources\ScriptTemplates

Assuming the default install directory.

Thx for the tipp, I just changed the default C# MonoDev template. BUT be careful, there’s a trap (at least on Win 7): Changing/Saving the file in the C:-Program Files (x86)-Unity-Editor-Data-Resources-ScriptTemplates isn’t allowed so I made a copy of the 81-C# Script-NewBehaviourScript.cs.txt file (for backup) directly in the folder (and this was the problem), then copied the original file somewhere outside, changed the content, and copied it back.

But from then on, something went wrong. I wasn’t able to create new C# scripts anymore. I tried a few things, but the only solution was to reinstall Unity again. Afterwards I tried it again, and this time it worked. This is what I did:

  1. Copied 81-C# Script-NewBehaviourScript.cs.txt to some other location on my harddrive
  2. Copied it again for backup reasons
  3. Changed the content of the file
  4. Copied it back to C:-Program Files (x86)-Unity-Editor-Data-Resources-ScriptTemplates and overwrote the original file
  5. → Works fine!

Hope this was helpful :slight_smile:

Cheers,
Christian

It’s annoying isn’t it.

Sadly that template seems to be embedded into the UnityUtilities.dll, which makes it annoying to change.

There is a solution, but its a pain to do.

If you go into options Preferences → External Tools → Script Editor and use a normal (non-bundled) version of mono develop you can write a custom Addin (see Redirecting…). This lets you add extra template options in the ‘new file’ dialog, and customise them however you like.

Better yet, if you upgrade, you can just install the addin again on your new copy of monodevelop.

Writing addins is quite a laborious process though. If you can be bothered, its worth it…

On OSX the folder where the default scripts are copied from can be found here (within your Unity folder)

Unity.app/Contents/Resources/ScriptTemplates

Edit the contents of 81-C# Script-NewBehaviourScript.cs.txt for C# scripts and also others (the names speak for themselves).

If you don’t know how to get inside the .app - Right (secondary) click on the .app and select*** Show Package Contents***