EditorUtility.DisplayDialog 显示对话框

static function DisplayDialog (title : string, message : string, ok : string, cancel : string = "") : bool

Description描述

Displays a modal dialog.

显示一个模态对话框。

Use it for displaying message boxes in the editor.

用于在编辑器显示消息框。

ok and cancel are labels to be displayed on the dialog buttons. If cancel is empty (the default), then only one button is displayed. DisplayDialog returns true if ok button is pressed.

ok 和 cancel 是显示在对话框按钮上的标签,如果cancel为空(默认),然只有一个按钮被显示。如果ok按钮被按下,DisplayDialog返回true。

参见:DisplayDialogComplex function.

EditorUtility.DisplayDialog 显示对话框

Dialog box that shows info on the number of objects to be placed on the surface.
对话框,其中显示的表面上放置对象的详细信息。

// C# Example

// Places the selected Objects on the surface of a terrain.

//在地形的表面上放置选择的物体。

using UnityEngine;

using UnityEditor;



public class PlaceSelectionOnSurface : ScriptableObject {

	[MenuItem ("Example/Place Selection On Surface")]

	static void CreateWizard () {

		Transform[] transforms = Selection.GetTransforms(SelectionMode.Deep |

		SelectionMode.ExcludePrefab | SelectionMode.OnlyUserModifiable);



		if (transforms.Length > 0 &&

			EditorUtility.DisplayDialog("Place Selection On Surface?",

			"Are you sure you want to place " + transforms.Length

			+ " on the surface?", "Place", "Do Not Place")) {

			foreach (Transform transform in transforms) {

				RaycastHit hit;

				if (Physics.Raycast(transform.position, Vector3.down, out hit)) {

					transform.position = hit.point;

					Random.onUnitSphere;

					randomized = new Vector3(randomized.x, 0F, randomized.z);

					transform.rotation = Quaternion.LookRotation(randomized, hit.normal);

				}

			}

		}

	}

}
Page last updated: 2011-7-15