- Home /
how can put open file window to my project to change texture in my project?
hello every one; i have a box in my stage. i want to put a button that when push it appear open file window that i select a picture then change texture that box .how can i do in your opinion.Good luck.
Answer by Bunny83 · Jun 23, 2012 at 11:38 AM
Unfortunately Unity doesn't offer support for native open / save-dialogs.
See this thread for a custom solution.
Keep in mind that file access is not available in a webbuild.
Answer by fateh · Jun 23, 2012 at 03:42 PM
thanx Bunny83 for reply but I do not agree with you.
i found something about this maybe useful for you too
Open File Panel.
class EditorUtilityOpenFilePanel {
@MenuItem("Examples/Overwrite Texture")
static function Apply () {
var texture : Texture2D = Selection.activeObject;
if (texture == null) {
EditorUtility.DisplayDialog(
"Select Texture",
"You Must Select a Texture first!",
"Ok");
return;
}
var path = EditorUtility.OpenFilePanel(
"Overwrite with png",
"",
"png");
if (path.Length != 0) {
var www = WWW("file:///" + path);
www.LoadImageIntoTexture(texture);
}
}
}
exactly, if you said you want a file open dialog, everyone would think you want that at runtime. If you talk about an editor script you should mention that.
Just to be clear: I used EditorUtility.DisplayDialog a lot in my editor scripts, but i don't really thought this question was about editor program$$anonymous$$g. The link i've posted also suggests EditorUtility.DisplayDialog and it also states that it only works in the editor.
Answer by Nelien · Jun 23, 2012 at 03:50 PM
Bunny83 is correct. And here's a more direct link to what can get you started.
Your answer
![](https://koobas.hobune.stream/wayback/20220613073155im_/https://answers.unity.com/themes/thub/images/avi.jpg)