Version: 2021.3

描述

在向导打开或者用户在向导中更改内容时,将调用此函数。

这允许您设置 helpStringerrorString,并通过 isValid 启用/禁用 Create 按钮。 此外,它还允许您在显示向导时更改标签(例如计时器标签)或按钮

另请参阅: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); } }