- Home /
The question is answered, right answer was accepted
Make Gallery from Array
Hi, I would like to have a folder that I can specify from string (I kind of know how to do this so far.) But I would like an array, and any, say: Movies or images - that go into the folder go into the array, and it can let you view them with the video texture feature..
How would I go about starting something like this?
Thanks
Answer by ArkaneX · Apr 30, 2014 at 12:25 PM
You can use classes from System.IO namespaces to achieve what you want. To get array of file paths, use Directory.GetFiles method. Having these paths, you can load the images/videos with WWW class, and access texture using WWW.texture or WWW.movie
Now the sad part... Remember, that Unity can only load PNG/JPG images and Ogg Theora videos. If you want to support other image formats, e.g. BMP, you'd have to convert them on the fly to one of Unity supported formats. You'd need a custom solution for this though. For example, you can use System.Drawing.Bitmap, but only if you target Windows (and possibly Mac/Linux - never tried it).
I know of no easy way to handle other video formats though. Transcoding on the fly would be impossible in real time, so I think the only solution is to use a MovieTexture alternative, if you find any...
Thanks for your help! :) this has helped me further develop what I am trying to do. As for the movie files, Ive never heard of Ogg Theora videos.. is it a type of format? Ive used .mov before and that works fine.
For more info about this format, take a look at wikipedia.
In Unity, you can use other video formats as well, but all video assets are internally converted to Ogg Theora (unless they are already in this format). If you read non-Theora movie from disk, then playing it won't be possible, as for Unity the format is unknown - there's no way to transcode on the fly.
Ogg Theora requirement is described in the documentation of WWW.movie and $$anonymous$$ovieTexture.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Unity c# indexoutofrangeexception: array index is out of range 1 Answer
Best way to keep track of objects on a 3D Grid? 2 Answers
How to debug values in jagged arrays? 0 Answers