A Developer's Resource
&
Co..

ZeredaGames

Let's Play!

 

Templates for Unity

As I make more, I'll post them on here, but I'll start with 4 or 5 and show you how to use them on this page. The link's to the templates are just below this comment. to learn how to use them scroll down a little further.

Currently testing templates, making more and adjusting scripts to make sure they work. Havne found bug's with current posted.
        ~Will fix very soon.
 

Where to find the files?

I have the Unity that I'm using in this tutorial installed in my secondary D drive on an SSD. I made a folder called Unity and let it install into there. Now to find this file, You much locate where You installed your Unity. Next, Navigate to the "Editor" folder and find the folder called "Data". In here you want to go to "Resources"and then in there "Scripts Templates".


Like so:


D:\Unity\Editor\Data\Resources\ScriptTemplates

Unity\Editor

Unity\Editor\Data

Unity\Editor\Data\Resources

Unity\Editor\Data\Resources\ScriptTemplates

Here you will find text files of the scripts Unity uses to create from. We can edit these.. There is one issue I haven't not figured out yet and I don't know if it can be changed, and that you can't seem to add more to the right click menu that come up when you right click in your project window to create a new script. If someone would like to enlighten me that would be wonderful. But for now I use this alternative.

My Alternative for now.

UPDATE: Found a way to add more script buttons to the menu list click here!



Example of ours to the right

Grab the "Scripts Templates" folder and drag it into the side bar into your fav's tab for ease of access at any time.
 
So The alternative we have is to change the existing 1 whenever we need to. There is a simple go around around that i use. Unity seems to load the lowest number and then a specific prefix, and then w.e the rest is, is w.e the new script will be called

Example:


      Unity default:  81-C# Script-NewBehaviourScript.cs

-------------------------------------------------------------------------------------------------

      My own: 78-C# Script-NewBehaviourScriptAdvanced.cs


number keeps them organized in the list
Script type = C# Script
after  the "  -  " is the name of the new script on creating if you don't name it when it gets creates aka default name.


So if i put:


       77-C# Script-ThisIsANewScript.cs

The new script in the project window will be called "ThisIsANewScript" is you hit enter upon creation and not type your own name in for the class.
Notice how there is an arrow beside the shader's and test script's? Create script doesn't have that and I'd like to know how to modify that.

Conclusion

What is happening here is because mine starts with the # 78, mine will load before the default. Now if i wanted to use the default I can do two things, I can change the number to 82 or completely delete it. Up to you. Myself I have multiples and I just swap the numbers around and have a quick link on my explorer in my favorites tab like the image in step 3. Please note, Keeping a copy of the original is good unless you break these trying to edit them. To fix may require a reinstall of Unity. Also note that Unity will overwrite any existing names that are the same when reinstalling. So to prevent loss of your templates it a goo practice to save a second copy else where for in case this does occur and make sure it has it's own custom unique name so unity doesn't overwrite it. if you uninstall Unity, your scripts will remain because it hasn't been programed to delete your custom files -names, or folders.

How do we edit?

If you have never done this, you will see "81-C# Script-NewBehaviourScript.cs" or "82-C# Script-NewBehaviourScript.cs" can't remember what the default number is off hand but it would be at the top.
When you open it op it should look something like this:
Here we can see it looks just like any other script we have ever made before. Please note the "#SCRIPTNAME#" This is pretty Important for making constructors and return types pre done.

Example:


Since this has been fully covered on the unity site I won't go to much further into this, so for more information on this subject click here

Here is a link to a way to load your scripts into an editor folder click Here
Here is a link to some more Template by some other users click here  or here