21. Create Script Wizard

  04. Features No Comments

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:

  1. Specify the namespace to use for your script. The default namespace can be configured in the Preferences.
  2. 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.
  3. Specify the Template to use when generating the code. For example MonoBehaviour, ScriptableObject or Plain Class.
  4. 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.
  5. 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).
  6. Specify which using directives you would like to include in the generated code.
  7. 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:

  1. The script asset will created, containing code generated based on your chosen settings.
  2. The created script asset will be opened in your External Script Editor.
  3. 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.