Legacy Documentation: Version 5.2
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorUtility.OpenFilePanel

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

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

Parameters

Description

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

See Also: SaveFilePanel function.


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