- Home /
Animated 2D GUI texture
I have been looking into animated 2d textures and have visited the unity site and read through the following docs.....
http://docs.unity3d.com/Documentation/ScriptReference/MovieTexture.Play.html
and......
http://docs.unity3d.com/Documentation/Manual/VideoFiles.html
I have tried this and it does work however the problem is I don't want to put this onto a material what I was really after was to make an animated GUI texture.
I have created a normal GUI texture as you would in code made a public plugin and placed my movie texture into that plugin but what I can't figure out is a way to display it on a GUI texture and get it to play without using a material and a 3dObject like plane.
Also tried casting it as a normal Texture and a Texture2D to no success was worth a try though but does anyone have any other ideas on this?
Thanks in advance.
Figured it out really easy probably took me a while cuz i been tired but anywayz code below to get it set up.....
using UnityEngine; using System.Collections;
public class example : $$anonymous$$onoBehaviour {
public $$anonymous$$ovieTexture animated_$$anonymous$$ovieHere;
void OnGUI() { GUI.Box(new Rect(10, 10, 100, 20), animated_$$anonymous$$ovieHere); { animated_$$anonymous$$ovieHere.Play(); } } }
Once this has been saved drag your animated movie into the public plugin in the inspector on your script and if it also has an audioclip attached drag that onto your object aswell then hey presto sorted!
This plays as a GUI texture and doesn't need any extra such as a material etc to play.
Answer by melonman · Oct 25, 2012 at 03:59 PM
Figured it out really easy probably took me a while cuz i been tired but anywayz code below to get it set up.....
using UnityEngine; using System.Collections;
public class example : MonoBehaviour {
public MovieTexture animated_MovieHere;
void OnGUI() { GUI.Box(new Rect(10, 10, 100, 20), animated_MovieHere); { animated_MovieHere.Play(); } } }
Once this has been saved drag your animated movie into the public plugin in the inspector on your script and if it also has an audioclip attached drag that onto your object aswell then hey presto sorted!
This plays as a GUI texture and doesn't need any extra such as a material etc to play.
Answer by Venryx · Mar 03, 2014 at 08:02 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