EditorApplication.ExecuteMenuItem 执行菜单项

static function ExecuteMenuItem (menuItemPath : string) : bool

Description描述

Invokes the menu item in the specified path.

调用指定路径的菜单项。

This function also works with Editor Scripts

此功能也可与编辑脚本一起作用。

// Simple script that lets you create a new

// scene, create a cube and an empty game object in the scene

//简单的脚本, 可以让你新建一个新的场景, 新建一个立方体和场景中的一个空物体

// Save the scene and close the editor

//保存场景并且关闭编辑器



import UnityEditor;



@MenuItem ("Example/Chain Actions and close")

static function Chain() {

	EditorApplication.NewScene();



	EditorApplication.ExecuteMenuItem("GameObject/Create Other/Cube");

	EditorApplication.ExecuteMenuItem("GameObject/Create Empty");



	EditorApplication.SaveScene("Assets/MyNewScene.unity");

	EditorApplication.Exit(0);

}
Page last updated: 2011-6-25