How to load objects from a file outside of unity3d


Is their a way to load files (videos, images) from outside of unity3d assets directory?

What i mean is if you program in a text field function and a button to search your directory on your hard drive for videos and images, would they show up dynamically in the standalone application when i try to search for a file? If so, can i get an idea of how this might be done? I know that this can be done on the server side of things, but the client i am working for wants to search for all his files on his hard drive. I know if i try to use resource.load(), it won't work since it has to be within the the unity assets directory.

Ok thank! So can all this be done on the Iphone using xcode?

you can use System.IO for searching in directories and you can load video(ogg format) and images(png) using WWW class in unity. The only thing you should do is pass your file path like this :

var url = "file://c:/fridays.jpg";
function Start () {
     // Start a download of the given URL
    var www : WWW = new WWW (url);

    // Wait for download to complete
    yield www;

    // assign texture
    renderer.material.mainTexture = www.texture; 

see WWW class reference in docs


For text files I do like this:

private var file : String = ""file://c:/files/file.txt";

var reader : StreamReader = File.OpenText(file);

You need to use file:///c:/… to let this file protocol work…3 slashes