言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

EditorUtility.OpenFilePanel

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

Description

"open file"ダイアログを表示し、選択されたパスを取得します

See Also: SaveFilePanel 関数
Open File Panel.

	// Opens a file selection dialog for a PNG file and overwrites any
	// selected texture with the contents.

	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);
			}
		}
	}