- Home /
How to call the open file dialog box during runtime
In my GUI application I must ask the user to browse for a file (I will have a more rigorous constraints regarding the kind of files I want the users to select, but that comes at a later time).
Now, I know there is a way to create menu item the Editor and all that sort but what I need is to be able to call the dialog box when the game is running. How do I start with that?
Can anyone help me figure out how to call the OpenFile dialog box while my game is running?
Thank you and have a good one!
Answer by RudyTheDev · Feb 24, 2014 at 07:10 PM
Check this answer. You'll probably have to use Mono's "Windows.Forms" .dll via "Plugins/".
I tried it but I get this error:
TypeLoadException: Could not load type 'System.Component$$anonymous$$odel.EditorAttribute' from assembly 'System, Version=2.0.0.0, Culture=neutral, Public$$anonymous$$eyToken=b77a5c561934e089'.
That answer did not exactly work for me as well as I had hoped. For one thing: the monodevelop 2.0 plugin folder did not exist in my computer, at all. Next, I did some digging to find out where I may find this system.windows.forms
thing and I found it in my windows folder but the problem is that when I copy paste the dll into my own project it gives me the error I pasted above.
Any idea on how I can fix it? Thank you in advance!
Well, you can't (just) use Windows-compiled .NET Forms and expect it to (always) work. Unity uses $$anonymous$$ono, which is "based" on .NET, but they implement many things differently. Forms is one of those things that are very OS-dependent. I'm not sure how compatible $$anonymous$$ono is with that. For start, you need to use $$anonymous$$ono-specific forms implementation and go from there. Otherwise your library will require other Windows libraries, which will require other ones, until you basically need vanilla .NET.
Answer by viju · Jan 27, 2016 at 03:17 PM
An alternative way: See my answer for http://answers.unity3d.com/answers/1134105/view.html
"*.*" can be customized like "*.bat", "Data_*.txt", etc.
Your answer

Follow this Question
Related Questions
A node in a childnode? 1 Answer
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Animate the scaling of a gameObject 4 Answers
Not getting component properly 1 Answer