- Home /
EditorUtility.OpenFilePanel() Multiple Extensions
How do I implement multiple extensions for selection?
I'm looking at selecting JPEG images, which have the annoying habit of an interchangeable extension (.jpg and .jpeg).
I've been trying to get this to work since Unity 3.5 (We're now on Unity 4.3), and I've yet to find any solution or a response from a Unity team member.
I've tried a long list of everything anyone has said to work.
".jpg;*.jpeg;"
'".jpg;*.jpeg;"'
".jpg;jpeg"
"jpg;jpeg"
"jpg|jpeg"
".jpg|.jpeg"
'".jpg|.jpeg"'
".jpg|*.jpeg"
'".jpg|*.jpeg"'
"jpg jpeg"
"jpg/jpeg"
"jpg:jpeg"
"*.jpg;*.jpeg;"
"*jpg;*jpeg"
"jpg,jpeg"
"\"jpg\",\"jpeg\""
It really shouldn't be this hard to get this to work, it's a common functionality expected in all file selection windows.
Here's some other threads from years ago that show people having the same problem: http://answers.unity3d.com/questions/521428/multiple-extensions-with-editorutilityopenfilepane.html#answer-785004 http://answers.unity3d.com/questions/308825/how-to-use-editorutilityopenfilepanel-to-filiter-m.html
For the last few years developing our Unity plugin, I've set this problem down and come back to it hoping there'd be a solution in the future. At this point it's just frustrating; it's not that big of a deal to ignore in our plugin, but we still get customer complaints that they can't select .jpeg images. Simply because Unity has failed to document how to handle multiple extensions, and their staff that look at these forums always seem to skip this question.
I really do appreciate any and all help in this matter, thank you for your future help in solving this obnoxious problem.
Has anyone had any success with this?
I've taken a peek at some things and it seems Unity supports a multiple extension file browser for importing new assets, but it isn't exposed to developers.
I believe it's RunOpenPanel() vs RunComplexOpenPanel() on the C++ side.
Can I get a response from someone at Unity about this?
Answer by Tryz · Jan 04, 2016 at 02:08 PM
Simply using a comma worked on Windows.
"fbx,prefab" resulted in both .fbx and .prefab files being shown.
Answer by vorion · Dec 14, 2014 at 10:04 PM
Here is a simple workaround try passing this: "Jpeg Interchange;*.jpg;*.jpeg"
to the OpenFilePanel extension parameter.
It works because the first parameter being passed to the OS seems to not be passed correctly. Further parameters are passed correctly. It is ugly but it works.
Answer by Peter77 · Feb 28, 2017 at 09:00 AM
In Unity 5.5 and later, they added a new method that accepts an array of file extensions:
EditorUtility.OpenFilePanelWithFilters(string title, string directory, string[] filters); https://docs.unity3d.com/ScriptReference/EditorUtility.OpenFilePanelWithFilters.html
Answer by brinis2023 · Dec 05, 2019 at 10:35 AM
void Start()
{
extensions = new List<ExtensionFilter>();
ExtensionFilter extensions2 = new ExtensionFilter("*",extensionsString);
extensions.Add(extensions2);
}
private void OnClick()
{
string[] paths = StandaloneFileBrowser.OpenFilePanel("Title","", extensions.ToArray(), false);
if (paths.Length > 0)
{
output.text = paths[0] + "";
// StartCoroutine(OutputRoutine(new System.Uri(paths[0]).AbsoluteUri));
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613162314im_/https://answers.unity.com/themes/thub/images/avi.jpg)