- Home /
Animating a Texture2D using cells
Hi,
Im trying to use the http://www.unifycommunity.com/wiki/?title=Animating_Tiled_texture_-_Extended>animating tile texture code from the Unify Community. I really like the idea, but im trying to figure out how to use this same principal on a texture2D copy instead of an objects material.
Is this possible? Or maybe too much work for the end result? If you know of a better way to do a tile animation on a texture, im all ears!
Thanks in advance!
I'm not sure I understand the question. Why would you want to do that? Almost all uses for texture2d objects work through materials- are you using this for GUI stuff?
@syclamoth yeah using it for gui stuff. $$anonymous$$ight be way to expensive to call, i might just make an array of textures and cycle through those ins$$anonymous$$d.
Using an array of textures sounds heavier than just offsetting one texture. Could you perhaps use a sprite attached to the camera and render it on top? It's easiest if you can use a material.
@save i gave it a try, but didnt have any success. The graphics draw texture turned out to be exactly what i needed. Thanks for the suggestion tho. Cheers
Answer by flamy · Apr 23, 2012 at 07:18 AM
You can use the same method for GUI in a much simpler way using Graphics.DrawTexture()
You can use the same method from that unify link for calculating uvs and jus pass the UV values to the above function.
Having an array of textures would be heavy never ever prefer it. Even if you want to do it with multiple textures, you gotta use Resources.Load(), with an array of string for the path of the textures. Any way you gotta call this function often to keep the memory in check.
Hope it helps :)
@vijayakumar Im not sure exactly where the UV coords come into play in the Graphics.DrawTexture() function. Can you give me an example of usage? It would be greatly appreciated. So far this sounds like the path i want to take.
Oh...source rect. Awesome, lemme give it a test and post my success.
@vijayakumar Works like a charm! Didnt have time to test yesterday, but it only took a few $$anonymous$$utes today to convert. Only needed an additional variable and 2 lines.
Thanks for the great answer.
Your answer
Follow this Question
Related Questions
Resizing GUI textures 0 Answers
animating terrain texture question 1 Answer
Scaling / Resizing an Image (Texture2D) 6 Answers
How to not see white background on texture 1 Answer
how to post rawimage.texture to wwwPOST method to my server as a PNG 0 Answers