Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Tehelee · Sep 04, 2014 at 04:41 PM · editoreditorutility

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.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tehelee · Oct 14, 2014 at 06:58 PM 0
Share

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?

avatar image frarees · Oct 15, 2014 at 10:38 AM 0
Share

$$anonymous$$aybe you can give some feedback or add an issue asking to expose the API for that.

4 Replies

· Add your reply
  • Sort: 
avatar image
3

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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



Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

27 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

forcing unload a file after error 0 Answers

use of EditorUtility.CompileCSharp 1 Answer

The Script Equivilent of dragging a hierarchy of meshes over a preexisting prefab? 0 Answers

Missing Method Exception when trying to access EditorJsonUtility class methods 3 Answers

How to use the ProgressBar (in an Editor script)? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges