Power Inspector comes with a Create Script Wizard, which makes it easy to create new script assets.
It is based on the excellent Create Script Dialog by Unity – which no longer seems to be available anywhere.
Opening The Create Script Wizard
To open the Create Script Window, first open the Add Component dialog, and then click the plus sign, or use the add component keyboard shortcut Ctrl + T.
Alternatively you can open it from the Project view’s Create menu using the menu item C# Script Wizard.
Using the Create Script Wizard
Using the Create Script Wizard, you can configure the following aspects of the created script:
- Specify the namespace to use for your script. The default namespace can be configured in the Preferences.
- Specify the name for your new script. If the Create Script Wizard was opened through a Add Component dialog which contained a filter text, then that filter text will automatically be used as the default value for this field.
- Specify the Template to use when generating the code. For example MonoBehaviour, ScriptableObject or Plain Class.
- Specify the GameObject onto which an instance of the created script should be attached. This option is only available when using the MonoBehaviour template. If the Create Script Wizard was opened through the Add Component button, this is mapped the target GameObject.
- Specify the path where the script asset should be saved. The default path can be configured in the Preferences. Currently you can change the path where you want to save the script asset by selecting a directory in the Project view (NOTE: when using Two Column Layout, this only works when selecting directories on the right-side column).
- Specify which using directives you would like to include in the generated code.
- Specify which functions you would like to include in the generated code.
One you’ve configured everything to your liking, press the “Create and Attach” button, at which point the following things will happen:
- The script asset will created, containing code generated based on your chosen settings.
- The created script asset will be opened in your External Script Editor.
- If “attach to” field has a value, the an instance of the created script will be attached to the GameObject in question as a new Component.