ScriptableWizard.DisplayWizardScripting > Editor Classes > ScriptableWizardstatic function DisplayWizard (title : string, klass : Type, createButtonName : string = "Create", otherButtonName : string = "") : ScriptableWizardDescriptionCreates a wizard with a given title. The klass has to derive from ScriptableObject and is the class implementing the wizard. When the user hits the Create button OnWizardCreate function will be called. DisplayWizard will only show one wizard for every wizard class (eg. WizardCreateLight in the example below) // C# example:
using UnityEditor; using UnityEngine; class WizardCreateLight : ScriptableWizard { public float range = 500; public Color color = Color.red; [MenuItem ("GameObject/Create Light Wizard")] static void CreateWizard () { ScriptableWizard.DisplayWizard("Create Light", typeof (WizardCreateLight), "Create", "Apply"); //If you don't want to use the secondary button simply leave it out: //ScriptableWizard.DisplayWizard("Create Light", typeof(WizardCreateLight)); } void OnWizardCreate () { GameObject go = new GameObject ("New Light"); go.AddComponent("Light"); go.light.range = range; go.light.color = color; } void OnWizardUpdate () { helpString = "Please set the color of the light!"; } // When the user pressed the "Apply" button OnWizardOtherButton is called. void OnWizardOtherButton () { // Simply set the color of the selected light to red. if (Selection.activeTransform == null) return; if (Selection.activeTransform.light == null) return; Selection.activeTransform.light.color = Color.red; } } |