Version: 2017.3

ScriptableWizard.OnWizardOtherButton()

切换到手册

描述

允许您在用户单击 Others 按钮时提供操作。

如果用户在调用 DisplayWizard 时单击辅助选项, 您就可以在此处实现将完成的所有操作。

另请参阅:ScriptableWizard.DisplayWizard

\ 具有“Other”按钮的 ScriptableWizard,在本例中,按钮名为“Info”。

// Display a window showing the distance between two objects when clicking the Info button.

using UnityEngine; using UnityEditor;

public class ScriptableWizardOnWizardOtherButton : ScriptableWizard { public Transform firstObject = null; public Transform secondObject = null;

[MenuItem("Example/Show OnWizardOtherButton Usage")] static void CreateWindow() { ScriptableWizard.DisplayWizard("Click info to know the distance between the objects", typeof(ScriptableWizardOnWizardOtherButton), "Finish!", "Info"); }

void OnWizardUpdate() { if (firstObject == null || firstObject == null) { isValid = false; errorString = "Select the objects you want to measure"; } else { isValid = true; errorString = ""; } }

// Called when you press the "Info" button. void OnWizardOtherButton() { float distanceObjs = Vector3.Distance(firstObject.position, secondObject.position); EditorUtility.DisplayDialog( "The distance between the objects is: " + distanceObjs + " Units", "", "Ok"); }

// Called when you press the "Finish!" button. void OnWizardCreate() { } }