2019.1 - New way to modify c# script template?

From the patch notes:

  • Editor: Exposed ProjectWindowUtil.CreateScriptAssetFromTemplateFile, allowing Editor scripts to create new text-based assets from template files in a similar way to how the built-in C# Script template is used.

Does this mean I can now edit the c# template script within unity or do I still have to manually find the template file and modify it?

You can edit the script template from within Unity already, it’s just not documented properly.

You simply copy the script templates from:
Unity Install Location/Editor/Data/Resources/ScriptTemplates
to:
Assets/ScriptTemplates

Make the edits you want, and then restart Unity. Those script templates will be used. This has been around forever, but since it didn’t get properly implemented (ie. you have to restart Unity to make changes), they never made docs for it.

CreateScriptAssetFromTemplateFile seems to do the same thing as the “Create/C# Script” menu item does; copy the script template, fill out the name and such, and then create it as an asset.

1 Like