C# code template

Is there any way to change the template code for new C# behaviours. I know what “Start” and “Update” are for and those default comments are beginning to annoy.

yupp you can change it in the Unity 3.1 install folder somewhere down the data folder

Yup, I think I saw a CS, JS and BOO scripts somewhere in data, resources folder or something. Pretty sure that the content of them is that template so if you change it, it should change the default template :wink:

As you know in C#, when you create a new class, you have to manually change a class name to the same class file name. If anyone knows how to change the template to automatically change a class name to a class file name, please post the solution. Less typing, less mistake!

Thanks!

MightyMac, in Mono you can press F2 (shortcut for Refactor / Rename) to rename the class, filename, and more simultaneously.

When I first discovered the feature, I thought it would be a timesaver. However, everytime you refactor/rename, you create an autosave of the original NewBehaviour file. The next time you open a new NewBehavior file, you have to answer a dialogue about what to do with the autosave file. I found that actually added more time to my workflow than I was spending typing in the classname twice, but ymmv.

Wow! I like my new screen name (MightyMac). Anyway, I forgot to mention that I use Miscrosoft Visual Studio 2010 (VS) as my script editor. Yep, I always use the F2 key to rename the class file name, but when you are in the VS, you have to rename your class to match the file name.

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

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