- Home /
Animated GIF as a texture on Iphone
Is there a way of playing animated GIFs through iPhone Unity?
Converting to a movie as an intermediate format wouldn't be an option unless it could be done on the fly.
Answer by Eric5h5 · Mar 15, 2010 at 02:33 PM
Aisde from tiling the animation to one texture, you can cycle through individual texture frames:
var frames : Texture2D[];
var framesPerSecond = 10.0;
function Update () {
var index : int = Time.time * framesPerSecond;
index = index % frames.Length;
renderer.material.mainTexture = frames[index];
}
On the more complex end of the spectrum, you can script an animated .gif parser and use actual animated .gif files. For smaller sizes the speed would probably be acceptable.
Don't know which script is faster / more efficient: Eric's or Joachim's (and here's an Extended version).
how come everytime i copy and paste someones script from here i get errors and cant play i did nothing to your script and it wont play im starting to get frustrated nothing seems to work for me
@kidrockkenny I'll try to tell this in the (least) sweetest way possible: you're doing it wrong. Now get back to your homework!!
Answer by Jaap Kreijkamp · Mar 15, 2010 at 07:29 AM
Short answer: no. Long answer, you can't play animated gifs, you can play movie textures on iPhone either. So depending on the size of the animation, you'll need to tile the animation to one texture and animate the tiles. Although it's meant for Second Life, it should work for Unity as well: link.
"you can play movie textures" I think you need to edit that...
Answer by GODLIKE · Jun 07, 2010 at 10:48 PM
There is a neat little script in the Unity Wiki that allows to "play" a series of textures without having to put them in a single one. You can also specify how many frames... very clean and effective. BUT you must convert your gif to a Unity readable format.
Is there a link with this information in a tutorial please dude?
That's the script Eric already quoted, made by himself: http://www.unifycommunity.com/wiki/index.php?title=Texture_swap_animator
This is why we don't like off-site links to code on StackOverflow. unifycommunity.com is domain-parked now.
@almo I'm willing to bet you are talking about mean my comment there. It has nothing to do with stackoverflow and it was actually acquired by Unity. No idea why they didn't kept the link references, though. Should have been simple enough. Anyway, you can just search for the title on the "new" wiki: http://wiki.unity3d.com/index.php/Texture_swap_animator - Also, Eric have already posted it in his answer, as I've tried to say.
@Cawas: I did ask them about it, and they agreed it was a problem, but in the end nothing happened. $$anonymous$$aybe whoever owns unifycommunity.com asked for too much money. I consider links to the forums and the wiki to be acceptable in answers here since they're all owned by Unity...if they go away, you can be pretty sure Answers is gone too.