脚本向导类。
using UnityEngine; using UnityEditor; using System.Collections; public class TestScriptableWizard : ScriptableWizard { //公共参数将显示在窗口中 public float range = 500; public Color color = Color.red; [MenuItem("GameObject/Create Light Wizard")] static void CreateWizard() { //第三个参数按钮为可选 ScriptableWizard.DisplayWizard<TestScriptableWizard>("Create Light", "Create", "OtherButton"); } //窗口中的值改变时,OnWizardUpdate被调用 void OnWizardUpdate() { UnityEngine.Debug.Log("OnWizardUpdate()"); helpString = "Please set the color of the light!"; errorString = "errorString"; } //当用户按下"Create"按钮,OnWizardCreate被调用 void OnWizardCreate() { UnityEngine.Debug.Log("OnWizardCreate()"); GameObject go = new GameObject("New Light"); go.AddComponent("Light"); go.light.range = range; go.light.color = color; } //当用户按下"OtherButton"按钮,OnWizardOtherButton被调用 void OnWizardOtherButton() { UnityEngine.Debug.Log("OnWizardOtherButton()"); if (Selection.activeTransform == null || Selection.activeTransform.light == null) return; Selection.activeTransform.light.color = Color.red;//把选中的物体设为红色 } }