EditorUtility.OpenFilePanel 打开文件面板

static function OpenFilePanel (title : string, directory : string, extension : string) : string

Description描述

Displays the "open file" dialog and returns the selected path name.

显示“open file”对话框,并返回选择的路径名。

参见:SaveFilePanel function.

EditorUtility.OpenFilePanel 打开文件面板

Open File Panel.
打开文件面板

// Opens a file selection dialog for a PNG file and overwrites any

// selected texture with the contents.

//打开一个PNG文件选择对话框,并覆盖任何选择的内容纹理

class EditorUtilityOpenFilePanel {

	@MenuItem("Examples/Overwrite Texture")

	static function Apply () {

		var texture : Texture2D = Selection.activeObject;

		if (texture == null) {

			EditorUtility.DisplayDialog(

			"Select Texture",

			"You Must Select a Texture first!",

			"Ok");

			return;

		}

		var path = EditorUtility.OpenFilePanel(

			"Overwrite with png",

			"",

			"png");

		if (path.Length != 0) {

			var www = WWW("file:///" + path);

			www.LoadImageIntoTexture(texture);

		}

	}

}
Page last updated: 2011-7-15