You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here you can set your Author Name and Email to add to your script's signature header. Also, you can choose to use the **local date format**: _9/13/2022 (en-US)_, for example, or the standard ISO format: _2022-09-13_. You need to click `Save` to store this data into
33
-
the [Editor Prefs](https://docs.unity3d.com/ScriptReference/EditorPrefs.html). You also have the option to clear the saved data.
32
+
Here you can preview in realtime what your script will look like, customize the values and copy the templates.
34
33
35
-
Immediately below that, we have a list of all included Script Templates and you can select them to locate the file.
36
-
You also have two buttons: `Copy to Project` and `Copy to Editor`. The first one will copy all script templates to the current project `Assets/ScriptTemplates` path,
37
-
limiting the script template usage to that project. The other will copy all script templates to your Editor folder, and you will be able to use the templates
38
-
in all projects. However if you don't have this package in a project, it will not replace the `#AUTHOR#` and `#CREATIONDATE#` keywords on the file.
34
+
### Settings
35
+
36
+
You can decide to enable both the Signature and the Namespace modules, each with their own set of custom settings.
37
+
38
+
#### Signature
39
+
40
+
The Signature module adds a simple signature header on your script following the template:
41
+
42
+
```cs
43
+
/**
44
+
* #SCRIPTNAME#.cs
45
+
* Created by: #AUTHOR#
46
+
* Created on: #CREATIONDATE#
47
+
*/
48
+
```
49
+
50
+
The `#SCRIPTNAME#` is no stranger to custom script templates, as it is replaced by the default Unity asset processor.
51
+
However, both the `#AUTHOR#` and `#CREATIONDATE#` will be replaced by the values you set on the `Author`, `Email(optional)` and `Use Local Date` fields under the Namespace module group.
52
+
53
+
#### Namespace
54
+
55
+
The Namespace module adds a namespace to your file, indenting the template content under it.
56
+
For that to work, you need to have a template such as:
57
+
58
+
```
59
+
#NAMESPACE#public class #SCRIPTNAME# : MonoBehaviour
60
+
{
61
+
public void Start()
62
+
{
63
+
64
+
}
65
+
}
66
+
```
67
+
68
+
Then, if enabled, the namespace will be replaced according to the values you set.
69
+
If you enable `Use Assembly Definition`, make sure the script is in the correct location to be linked to an assembly definition, or the `Default Namespace` will be applied.
70
+
Otherwise, if you decide to just use the `Default Namespace`, then it will be applied to all scripts.
71
+
Additionally, you can choose whether the auto indent use spaces or tabs and their amounts.
72
+
73
+
Finally, you should `Save` your changes once you're satisfied with your settings, to make sure they will be used whenever creating a new script.
74
+
You also have the option to `Clear` those settings at any time, if you wish.
75
+
This data is saved to the [Editor Prefs](https://docs.unity3d.com/ScriptReference/EditorPrefs.html) cache.
76
+
77
+
### Templates
78
+
79
+
This section shows a list of all included Script Templates and you can select them to locate the file.
80
+
You also have two buttons: `Copy to Project` and `Copy to Editor`.
81
+
The first one will copy all script templates to the current project `Assets/ScriptTemplates` path, limiting the script template usage to that project.
82
+
The other will copy all script templates to your Editor folder, and you will be able to use the templates
83
+
in all projects.
84
+
However if you don't have this package in a project, it will not replace the custom keywords on the file and might lead to compilation issues.
39
85
Also, if you update the Unity Editor version, you will lose the script templates and require to copy them again. This is not necessary if you copy them to your project.
40
86
Both actions of copying to project and to editor will require an editor restart to take effect.
41
87
42
88
How it works
43
89
---
44
90
45
-
The custom Script Templates have the keywords `#AUTHOR#` and `#CREATIONDATE#` that will be replaced by the data you entered on the Editor
46
-
Window and the present date. The keyword `#SCRIPTNAME#` is automatically replaced by Unity. All other keyword recognition and replacing is
47
-
done by the [ScriptKeywordProcessor](Assets/CustomScriptTemplate/Editor/ScriptKeywordProcessor.cs) class.
91
+
The custom Script Templates have custom keywords that will be replaced by the data you entered on the Editor Window and the present date.
92
+
The keyword recognition and replacing is done by the [ScriptKeywordReplacer](Assets/CustomScriptTemplate/Editor/ScriptKeywordReplacer.cs) class.
48
93
49
94
Customization
50
95
---
51
96
52
-
You can customize your Script Templates to suit your needs, for example adding default methods or even new keywords to process. Keep in
53
-
mind that if you ever want a feature that it does not have, I may want to include it on this package.
97
+
You can customize your Script Templates to suit your needs, for example adding default methods or even new keywords to process.
98
+
Just make sure you add them to the correct folder and add the custom keywords following the same rules as the built-in templates.
99
+
Keep in mind that if you ever want a feature that it does not have, I may want to include it on this package.
54
100
55
101
But, why?
56
102
---
57
103
58
-
I like to have my scripts signed so everyone knows who to ask when they have doubts. Unfortunately with every new version of Unity,
59
-
I have to redo the tedious process of updating my Script Templates manually. I'd very much like to be able to [manage my Script Templates
60
-
over the Unity Hub](https://forum.unity.com/threads/feature-request-manage-script-templates.532962/), but looks like no one else
61
-
uses it.
104
+
It all started when I wanted to have my scripts signed so everyone knows who to ask when they have doubts.
105
+
Unfortunately with every new version of Unity, I had to redo the tedious process of updating my Script Templates manually.
106
+
I'd very much like to be able to [manage my Script Templates over the Unity Hub](https://forum.unity.com/threads/feature-request-manage-script-templates.532962/), but it's a very minor feature.
0 commit comments