Editor utility open file panel proper usage


How do i implement the script linked above. Is it java or other?

Thx so much for the help! Peter

this function is a function just like others in editor classes. you can copy and paste the sample to a javascript and use it. for C# you should add a "using unityEditor" at the top of your source code. the function shows a open dialog and returns the path of the selected file. if the path's length is 0 then it means the user pressed cansel or closed the window without choosing a file.

how do I execute the file after copying?
also can i use this in runtime?

Do you mean you want to see them in the project panel? Then you should update the asset database:


Then if you want to refer to the imported object you can use:

Sprite sprite = AssetDatabase.LoadAssetAtPath(loc, typeof(Sprite)) as Sprite;

assuming your imported asset is a Sprite type.

NOTE that loc is the relative path, not the absolute path you get from “EditorUtility.OpenFilePanel”. For instance this is the right path to your asset:

loc = "Assets\Models\Background\window.png"