版本:Unity 6(6000.0)
语言英语
  • C#

ScriptableWizard.OnWizardOtherButton()

建议变更

成功!

感谢您帮助我们提高 Unity 文档的质量。尽管我们无法接受所有提交,但我们会阅读用户提出的每条建议的变更,并在需要时进行更新。

关闭

提交失败

出于某种原因,无法提交您的建议的变更。请在几分钟后</a>重试。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

说明

允许您在用户单击其他按钮后提供操作。

当用户在调用 DisplayWizard 时单击次要选项时,您可以在此处实现所有将要完成的操作。

其他资源:ScriptableWizard.DisplayWizard


带有“其他”按钮的可编程向导,在本例中名为“信息”。

// 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 || secondObject == 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() { } }