x


How to load objects from a file outside of unity3d

Hi,

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?

more ▼

asked Apr 16 '11 at 05:15 PM

dreal gravatar image

dreal
45 6 6 12

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

you can use http://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

more ▼

answered Apr 16 '11 at 05:27 PM

AliAzin gravatar image

AliAzin
2.5k 41 56 78

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

Apr 19 '11 at 04:50 AM dreal

I don't have the iphone version, but it should work with iphone too.

Apr 19 '11 at 05:30 PM AliAzin
(comments are locked)
10|3000 characters needed characters left

Hi,

For text files I do like this:

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

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

answered Apr 16 '11 at 06:04 PM

Uzquiano gravatar image

Uzquiano
480 22 25 35

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

Apr 19 '11 at 04:46 AM dreal

Well... I have never develop Unity for iPhone but I think it should work. And about Xcode, it is only a tool, what matter is what you write in there ;)

Apr 19 '11 at 08:07 AM Uzquiano
(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Jan 24 at 06:51 AM

ravi_gohil999 gravatar image

ravi_gohil999
1 2 4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x280
x217
x92
x52
x17

asked: Apr 16 '11 at 05:15 PM

Seen: 3565 times

Last Updated: Jan 24 at 06:51 AM