Derive from this class to create an editor wizard.
Editor wizards are typically opened using a menu item.
#pragma strict // 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 red public class WizardCreateLight extends ScriptableWizard { public var range: float = 500; public var color: Color = Color.red; @MenuItem("GameObject/Create Light Wizard") static function CreateWizard() { ScriptableWizard.DisplayWizard.<WizardCreateLight>("Create Light", "Create", "Apply"); //ScriptableWizard.DisplayWizard<WizardCreateLight>("Create Light", "Create"); } function OnWizardCreate() { var go: GameObject = new GameObject("New Light"); var lt: Light = go.AddComponent.<Light>(); lt.range = range; lt.color = color; } function OnWizardUpdate() { helpString = "Please set the color of the light!"; } // When the user pressed the "Apply" button OnWizardOtherButton is called. function OnWizardOtherButton() { if (Selection.activeTransform != null) { var lt: Light = Selection.activeTransform.GetComponent.<Light>(); if (lt != null) { lt.color = Color.red; } } } }
// 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 red
using 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 pressed 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; } } } }
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. |
DrawWizardGUI | Will be called for drawing contents when the ScriptableWizard needs to update its GUI. |
DisplayWizard | Creates a wizard. |
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. |
focusedWindow | The EditorWindow which currently has keyboard focus. (Read Only) |
mouseOverWindow | The EditorWindow currently under the mouse cursor. (Read Only) |
autoRepaintOnSceneChange | Does the window automatically repaint whenever the scene has changed? |
maximized | Is this window maximized. |
maxSize | The maximum size of this window. |
minSize | The minimum size of this window. |
position | The position of the window in screen space. |
titleContent | The GUIContent used for drawing the title of EditorWindows. |
wantsMouseMove | Does the GUI in this editor window want MouseMove events? |
hideFlags | Should the object be hidden, saved with the scene or modifiable by the user? |
name | The name of the object. |
BeginWindows | Mark the beginning area of all popup windows. |
Close | Close the editor window. |
EndWindows | Close a window group started with EditorWindow.BeginWindows. |
Focus | Moves keyboard focus to this EditorWindow. |
RemoveNotification | Stop showing notification message. |
Repaint | Make the window repaint. |
SendEvent | Sends an Event to a window. |
Show | Show the EditorWindow. |
ShowAsDropDown | Shows a window with dropdown behaviour and styling. |
ShowAuxWindow | Show the editor window in the auxiliary window. |
ShowNotification | Show a notification message. |
ShowPopup | Shows an Editor window using popup-style framing. |
ShowUtility | Show the EditorWindow as a floating utility window. |
GetInstanceID | Returns the instance id of the object. |
ToString | Returns the name of the game object. |
FocusWindowIfItsOpen | Focuses the first found EditorWindow of specified type if it is open. |
GetWindow | Returns the first EditorWindow of type t which is currently on the screen. |
GetWindowWithRect | Returns the first EditorWindow of type t which is currently on the screen. |
Destroy | Removes a gameobject, component or asset. |
DestroyImmediate | Destroys the object obj immediately. |
DontDestroyOnLoad | Makes the object target not be destroyed automatically when loading a new scene. |
FindObjectOfType | Returns the first active loaded object of Type type. |
FindObjectsOfType | Returns a list of all active loaded objects of Type type. |
Instantiate | Returns a copy of the object original. |
CreateInstance | Creates an instance of a scriptable object. |
bool | Does the object exist? |
operator != | Compares if two objects refer to a different object. |
operator == | Compares two object references to see if they refer to the same object. |
Awake | Called as the new window is opened. |
OnDestroy | OnDestroy is called when the EditorWindow is closed. |
OnFocus | Called when the window gets keyboard focus. |
OnGUI | Implement your own editor GUI here. |
OnHierarchyChange | Called whenever the scene hierarchy has changed. |
OnInspectorUpdate | OnInspectorUpdate is called at 10 frames per second to give the inspector a chance to update. |
OnLostFocus | Called when the window loses keyboard focus. |
OnProjectChange | Called whenever the project has changed. |
OnSelectionChange | Called whenever the selection has changed. |
Update | Called multiple times per second on all visible windows. |
Awake | This function is called when the ScriptableObject script is started. |
OnDestroy | This function is called when the scriptable object will be destroyed. |
OnDisable | This function is called when the scriptable object goes out of scope. |
OnEnable | This function is called when the object is loaded. |