Template Keywords

Template Keywords

There are specific, built-in keywords that are used in the process of generating script files from templates.  These vary in functionality from outputting the script's name to outputting the script's methods.  The current built-in keywords are outlined below.  Note that the # around the keyword are required for the template parser to correctly recognize your keywords.

 

#SCRIPTHEADER#

Outputs the header information for the current script.  This includes the namespace (if applicable) and any comment information for the class.

This should be near the top of your template file -- just after your using statements, but before your class declaration.

 

#SCRIPTNAME#

Outputs the name (or Type) for the current script.  This is most often used when declaring a class, for example:

public class #SCRIPTNAME# : MonoBehaviour

This keyword can (and should!) also be used wherever the current script's Type needs to be inserted.  A good example would be setting up a default constructor -- or perhaps casting a value to the current script's type.

 

#NICESCRIPTNAME#

Outputs a "nicified" version of the current script's name (or Type).  This can be used anywhere to output a "human-readable" version of the current script's type.  A good example would be declaring a MenuItem:

[MenuItem("GameObject/#NICESCRIPTNAME#")]

 

#SCRIPTMETHODS#

Outputs all of the methods that were selected via the Script Creation Wizard.  Generally this will be the only thing inside of your template's class declaration, but if you include your own, hard-coded methods in templates this keyword can come either before or after your built-in methods.

 

#TARGETCLASSNAME#

For Custom Editor templates only!
Outputs the name (or Type) of the class that's set as the Custom Editor's target (i.e. the Type that the Custom Editor is being created for).