ScriptableWizard
Derive from this class to create an editor wizard.
Read time 8 minutesLast updated 2 days ago
Definition
- Type: Class
- Namespace: UnityEditor
- Assembly: UnityEditor.CoreModule
- Inherits from: EditorWindow
public class ScriptableWizard : EditorWindow
Remarks
Editor wizards are typically opened using a menu item.
Examples
// Creates a simple wizard that lets you create a Light GameObject// or if the user clicks in "Apply", it will set the color of the currently// object selected to redusing UnityEditor;using UnityEngine;public class WizardCreateLight : ScriptableWizard{ public float range = 500; public Color color = Color.red; [MenuItem("GameObject/Create Light Wizard")] static void CreateWizard() { ScriptableWizard.DisplayWizard<WizardCreateLight>("Create Light", "Create", "Apply"); //If you don't want to use the secondary button simply leave it out: //ScriptableWizard.DisplayWizard<WizardCreateLight>("Create Light", "Create"); } void OnWizardCreate() { GameObject go = new GameObject("New Light"); Light lt = go.AddComponent<Light>(); lt.range = range; lt.color = color; } void OnWizardUpdate() { helpString = "Please set the color of the light!"; } // When the user presses the "Apply" button OnWizardOtherButton is called. void OnWizardOtherButton() { if (Selection.activeTransform != null) { Light lt = Selection.activeTransform.GetComponent<Light>(); if (lt != null) { lt.color = Color.red; } } }}
Properties
Property | Description |
|---|---|
| createButtonName | Allows you to set the text shown on the create button of the wizard. |
| errorString | Allows you to set the error text of the wizard. |
| helpString | Allows you to set the help text of the wizard. |
| isValid | Allows you to enable and disable the wizard create button, so that the user can not click it. |
| otherButtonName | Allows you to set the text shown on the optional other button of the wizard. Leave this parameter out to leave the button out. |
Methods
Method | Description |
|---|---|
| DrawWizardGUI | Will be called for drawing contents when the ScriptableWizard needs to update its GUI. |
| OnWizardCreate | This is called when the user clicks on the Create button. |
| OnWizardOtherButton | Allows you to provide an action when the user clicks on the other button. |
| OnWizardUpdate | This is called when the wizard is opened or whenever the user changes something in the wizard. |
Static Methods
Method | Description |
|---|---|
| DisplayWizard | Creates a wizard. |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |