EditorUtility.OpenFilePanel Manual     Reference     Scripting  
Scripting > Editor Classes > EditorUtility
EditorUtility.OpenFilePanel

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

Description

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

See Also: SaveFilePanel function.

// Opens a file selection dialog for a PNG file and overwrites any
// selected texture with the contents.
@MenuItem("Assets/Overwrite Texture")
static function Apply () {

var texture : Texture2D = Selection.activeObject as Texture2D;
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 = new WWW ("file:///" + path);
www.LoadImageIntoTexture(texture);
}
}