ScriptableWizard.OnWizardOtherButton 当向导带其他按钮

function OnWizardOtherButton () : void

Description描述

Allows you to provide an action when the user clicks on the other button.

当用户在其他按钮点击时,允许您提供一个动作。

This is the place where you can implement all the stuff that will be done if the user clicks the secondary option when calling DisplayWizard.

这里是你实现所有东西的地方,当调用DisplayWizard,如果用户点击第二选择时,将调用。

参见:ScriptableWizard.DisplayWizard

ScriptableWizard.OnWizardOtherButton 当向导带其他按钮

Scriptable Wizard with an "Other" button, in this case named "Info".
脚本化向导带有其他按钮,这里名字是Info。

// C#
// Display a window showing the distance between two objects when clicking the Info button.
//显示一个窗口,当点击Info按钮,显示两个物体之间的距离

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 objecst",
		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.
	//当按下Info按钮时调用
	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.
	//当按下Finish按钮时调用
	void OnWizardCreate() {
		return;
	}
}
最后修改:2011年6月25日 Saturday 15:16

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。