Do you ever want to create a simple C# script file, but Unity's default script comes with a lot of padding?
Leo's Templater provides an easy way to create different kinds of scripts, just the way you like them. Use the default scripts that come with the package or create your own, change the way you create scripts.
The templates will appear under Create/Templates
.
- Generate scripts using templates
- Add Header and/or Footer to created scripts
- Built-in templates (C# Class, Interface, Scriptable Object)
- Support subfolder templates (Will appear in sub menus in the templates)
Installing as GIT dependency via Package Manager
-
Open Package Manager (Window -> Package Manager)
-
Click
+
button on the upper left of the window, select "Add mpackage from git URL...' -
Enter the following URL and click the
Add
buttonhttps://github.com/Mercury-Leo/LeosTemplater.git
To create a new Template first you must change the Templater to search for custom templates. To change the templates folder location go to Edit/Preferences/Leo's Tools/Templates
select the new template folder location.
First create a new file inside the Templates folder, {templateName}.cs.txt
Edit the file to your specification.
This is a basic script template:
namespace #NAMESPACE#
{
public class #SCRIPTNAME#
{
#NOTRIM#
}
}
- '#NAMESPACE#' will automatically try and assign the correct namespace to the generated script.
- '#SCRIPTNAME#' will assign the script name when generated.
- '#NOTRIM#' prevents an empty space from being deleted.
To change the Header and Footer of scripts head to Edit/Project Settings/Leo's Tools/Templates
.
Edit the Header and Footer to your liking, both will appear commented out at the top and bottom of the genereated script respectfully.
Scriptable object
using UnityEngine;
namespace #NAMESPACE#
{
[CreateAssetMenu(fileName = "new#SCRIPTNAME#", menuName = "#SCRIPTNAME#")]
public class #SCRIPTNAME# : ScriptableObject
{
#NOTRIM#
}
}