- Home /
Animated GIF and Audio Instead of Video?
Since I'm using Unity Free, I know I'm not able to insert any type of video file into my game. However, I have been looking around, and I've come across that animated GIF files can be used in Unity. If so, how can I project an animated GIF onto my whole screen (or more or so, just show the GIF full-screen).
Also, since I can do that, I was wondering if I could also play an audio file over that, maybe to accompany the animated GIF. Is that also possible?
-Biendeo
Answer by Ashkan_gc · Sep 22, 2010 at 06:56 AM
it's not possible to play animated gifs in unity. you can convert them to a strip or multiple textures and then change the texture of your material yourself. see this question.
you can play audio using an audio source when animating your texture.
you can also write your own gif parser if you want.
using animated gifs instead of movies is not an option for long videos.
Answer by yoyo · Nov 24, 2010 at 06:03 PM
I wrote a "video" player for the free version of Unity. (I called it BMovieTexture, since it's a low budget version of the MovieTexture class). It triggers an audio clip, then plays back a sequence of images at an appropriate frame rate.
I used ffmpeg (freely available) to rip video into individual frames and extract the audio. I then load the frames one by one from the hard drive and display them, monitoring elapsed time to control playback speed. Unity free doesn't have an asynchronous file loader, but I was able to get some asynchronicity by using the WWW interface (with a "file://" URL).
Without full asynchronous streaming, performance isn't the greatest. On my laptop (relatively new and fast) I can play 1280x720 video at about 15 frames/second. Quarter-resolution is fine at 30 fps.
If anyone is interested I can dig up more details.
Hmm, 1280x720 may have been a lie, on looking back at the content I think I rescaled to 640x360 to improve load times.
I am certainly interested in this. Being unable to afford Unity Pro but requiring the functionality, I am between a rock and a hard place. Any help or advice would be awesome - but I would looking for something relatively simple being a novice.
@yoyo, I looked at the web player demo on your website for B$$anonymous$$ovieTexture, and it looks impressive. I would be very interested in seeing the details/code for that! Thank you!
Answer by Venryx · Mar 03, 2014 at 08:01 PM
You could also try a script like the following, which makes use of Mono's System.Drawing library: http://wiki.unity3d.com/index.php/AnimatedGifDrawer
Your answer
Follow this Question
Related Questions
How to play Video on canvas (RawImage)? 0 Answers
Ustream Support 1 Answer
video media encoder addframe texture format 5 expected to be 4 1 Answer
Play MP4 on UI? (Unity 3D 2018.2) 0 Answers