它会在向导打开或每次用户在向导中更改内容时调用。
这将允许您通过helpString、errorString和isValid设置helpString、errorString并启用/禁用“创建”按钮。它还允许您在显示向导时更改标签(例如,对于计时器)或按钮
其他资源:ScriptableWizard.DisplayWizard
用于克隆游戏对象的 ScriptableWizard 窗口。
// Simple Wizard that clones an object several times.
using UnityEngine; using UnityEditor; using System.Collections;
public class CloneObjects : ScriptableWizard { public GameObject objectToCopy = null; public int numberOfCopies = 2; [MenuItem("Example/Clone objects")] static void CreateWindow() { // Creates the wizard for display ScriptableWizard.DisplayWizard("Clone an object.", typeof(CloneObjects), "Clone!"); }
void OnWizardUpdate() { helpString = "Clones an object a number of times and move the cloned objects to the origin"; if (!objectToCopy) { errorString = "Please assign an object"; isValid = false; } else { errorString = ""; isValid = true; } }
void OnWizardCreate() { for (int i = 0; i < numberOfCopies; i++) Instantiate(objectToCopy, Vector3.zero, Quaternion.identity); } }