- Toolkit for Unity editor script templates.
- Quickly Edit/Save Unity editor script templates.
- Auto insert file header comments into the new script.
- Auto mark create date and copyright year.
- Unity 5.0 or above.
- .Net Framework 3.5 or above.
- In fact, the script templates store under the Unity editor install path, example “Unity 5.0.0f4\Editor\Data\Resources\ScriptTemplates”.
- Unity provide the API(OnWillCreateAsset method of the AssetModificationProcessor class) to capture the event of user create asset(include script) in Unity editor.
- Create editor code, inherit from EditorWindow class to draw our editor UI, and use our editor to Edit/Save Unity script templates.
- Define mark string, “#CREATEDATE#” mark create date of script and “#COPYRIGHTYEAR#” mark copyright year of code.
- Create our style script templates.
- When you create a script file in Unity editor Project, Unity engine will copy the corresponding template to the new file.
- Create our editor code, inherit from AssetModificationProcessor class and achieve the OnWillCreateAsset(string assetPath) method to capture the event of create asset(include script), read the new script text and replace the “#CREATEDATE#” to current date and replace the “#COPYRIGHTYEAR#” to current year.
Templates in the path “ScriptTemplateToolkit/Templates” provide reference to you to create your style script templates.
The format of copyright statement in the templates reference from the U.S. Copyright Office.
- Script Template Editor.
- If the notified message is “Access to the path … is denied.” when you save the template, close your Unity and restart it as an administrator.
- If you have any questions, feel free to contact me at email@example.com.