CREATE CODE TEMPLATES
VIDEO TUTORIAL(spanish text).
Project download link.
Translation:
Used to modify the original code inserted by Unity. We may include libraries, and other methods or references.
For example, we have a base class with abstract and virtual methods. We can prepare a code template with the methods that we can or should override.
Process:
- To create the template, Create a script as we would normally, named ‘template’ for example.
Compile(Save) it, to check some error, and finally substitute the name of the class to #CLASSNAME# label and save it as .txt
#CLASSNAME# is the name of the label that I have chosen. You can modify in ApplyTemplate class (in CodeTemplate namespace).
-
Delete ‘template’ script. Only we need .txt file.
-
The following will create access menu. To create shortcuts to different languages of code that can be created in Unity, I created classes for each type of language(BooTemplates, CSharpTemplates, etc…)
We create shorcuts menu in Create–>Templates–>Language(CSharp, Boo, …) using MenuItem before public static method in corresponding class(csharp template in CSharpTemplates, javascript template in JavaScriptTemplates, etc…).
Use:
- Create a script as we would normally. Then, with the new script selected in Project window, We apply the template found in the menu Create–> Templates, we created earlier.