- Home /
Write a Editor to select file from disk and import to unity
Hello, I need help ,i want to write a editor to import texture from disk,the function is you press the "Import" button ,it can pop a window to you ,you can select file from disk ,like "Assets -- Import New Assets",but i don't know how to pop the selection window
Answer by fafase · Oct 26, 2013 at 08:08 AM
Fact is Unity won't let you do that directly. There is this:
http://docs.unity3d.com/Documentation/ScriptReference/EditorUtility.OpenFilePanel.html
which only work in Editor mode meaning you won't be able to put that in a build.
You may think it is exactly what you need and wonder why they would not allowed that in the build, security. I could sell you an application that on the front allows to save and open file from your hard drive, but in the meanwhile, on the back, I am scanning your computer, sending all your personal pictures (even the kinky ones :)) and sending them to my blog.
Now there are solutions though, first if your game is a web player, you can use Javascript, the real one, the web one and make a small method
http://stackoverflow.com/questions/6463439/how-to-open-a-file-browse-dialog-using-javascript
that opens up a file explorer, the method is then called using Application.ExternalCall.
Otherwise there is this: http://wiki.unity3d.com/index.php?title=ImprovedFileBrowser
Your answer
Follow this Question
Related Questions
Extending support for other file formats. 1 Answer
How do I make copies of my Font with an editor script? 2 Answers
All Asset Previews for Prefabs and Models are fully black. 3 Answers
Getting properties on 'missing' things in Editor Scripts? 4 Answers
Editor re-creates fbm subfolder with model textures already existing in project 0 Answers