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.

more ▼

asked Mar 15, 2010 at 06:45 AM

avatar image

633 27 24 30

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

3 answers: sort voted first

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.

more ▼

answered Mar 15, 2010 at 02:33 PM

avatar image

120k 69 345 765

Don't know which script is faster / more efficient: Eric's or Joachim's (and here's an Extended version).

Nov 25, 2011 at 03:56 PM Cawas

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

Feb 01, 2012 at 09:31 PM kidrockkenny

@kidrockkenny I'll try to tell this in the (least) sweetest way possible: you're doing it wrong. Now get back to your homework!!

Feb 02, 2012 at 12:58 PM Cawas
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Mar 15, 2010 at 07:29 AM

avatar image

Jaap Kreijkamp
7.3k 46 70 114

"you can play movie textures" I think you need to edit that...

Nov 20, 2014 at 09:21 PM almo
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jun 07, 2010 at 10:48 PM

avatar image

529 16 16 31

Is there a link with this information in a tutorial please dude?

Nov 11, 2011 at 02:41 AM MightyMatty

That's the script Eric already quoted, made by himself: http://www.unifycommunity.com/wiki/index.php?title=Texture_swap_animator

Nov 25, 2011 at 03:51 PM Cawas

This is why we don't like off-site links to code on StackOverflow. unifycommunity.com is domain-parked now.

Nov 20, 2014 at 09:22 PM almo

@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.

Nov 24, 2014 at 02:57 PM Cawas

@Cawas: I did ask them about it, and they agreed it was a problem, but in the end nothing happened. Maybe 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.

Nov 26, 2014 at 03:44 AM Eric5h5
(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



Answers and Comments



asked: Mar 15, 2010 at 06:45 AM

Seen: 14774 times

Last Updated: Nov 26, 2014 at 03:44 AM