- Home /
OpenFilePanel, but how? - SOLVED!
Hi everyone, I am working on a big project, but at the moment I just want to know how to use "OpenFilePanel". I want to open a movie file. In the Scripting API there was an example, but it didn't work. And there are no tutorials about this. So, if you know how this works, just answer my question.
Looking forward to good answers, :D
G-Force Media
I just try to open a file in the program to use it then like a prefab
"-1 ANSWERS BUG" Apparent here.
$$anonymous$$ODERATORS - Do not convert comments to answers that were submitted using anything but the "VISIBLE TO EVERYONE" option. Otherwise the answer disappears to the ether.
Answer by Jessespike · Jun 19, 2015 at 05:17 PM
What do you mean it doesn't work? Are you getting an error?
The example does indeed work. The script needs to be placed in a folder named "Editor" as mentioned here and here.
Thanks for your answer, but it doesn't seem better. I get the same error. $$anonymous$$aybe I'm just too "noob" to understand the problem.
Here are some screenshots:
Script: http://answers.unity3d.com/storage/attachments/48516-openfile.png
Errors: http://answers.unity3d.com/storage/attachments/48518-openfile3.png
Thanks for answering, but it doesn't work even with the Editor folder. Oh, and I want to import the file in the program to use it then like a prefab. I think I'm just too dumb to understand the problem. o_O
Here are some screenshots:
Line 8 is where the error is reported. The final m in $$anonymous$$enuItem
isn't coloured correctly, so I wonder if the $$anonymous$$enuItem
has a hidden character.
The example is written in javascript, but you're using it like C#. Here's the example converted to C#
using UnityEditor;
using UnityEngine;
using System.Collections;
public class EditorUtilityOpenFilePanel : ScriptableObject {
[$$anonymous$$enuItem("Examples/Overwrite Texture")]
static void Apply () {
Texture2D texture = (Texture2D) Selection.activeObject;
if (texture == null) {
EditorUtility.DisplayDialog(
"Select Texture",
"You $$anonymous$$ust Select a Texture first!",
"Ok");
return;
}
string path = EditorUtility.OpenFilePanel(
"Overwrite with png",
"",
"png");
if (path.Length != 0) {
WWW www = new WWW("file:///" + path);
www.LoadImageIntoTexture(texture);
}
}
}
Oops... But, you know, everybody makes mistakes. ^_^ Thanks for your answer and the conversion!
Aaaannnnnnd... SOLVED!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Burgzergarcade Why am i getting an error after re-importing? 1 Answer
DLL Import => Build finish without Error but Can't Work 0 Answers
[c#] DirectSound in Unity 0 Answers