Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Marckeeling on February 21, 2014, 04:38:59 PM

Title: Scrolling UV Animation
Post by: Marckeeling on February 21, 2014, 04:38:59 PM
Hi

I was wondering if there was now a simple way to achieve this effect? http://www.youtube.com/watch?v=2CBTFqWioD4

This effect features a great deal in my design and I'm struggling to find a way whilst also using sprite sheets.
Any help would be really appreciated.
Thanks
Title: Re: Scrolling UV Animation
Post by: ArenMook on February 21, 2014, 04:48:49 PM
Easiest way to achieve that would be to overlay a UITexture on top of your button's background, and scroll it by adjusting its UV rect.
Title: Re: Scrolling UV Animation
Post by: BeShifty on February 21, 2014, 04:56:57 PM
Hey that was my video. Since implementing the script, NGUI has changed significantly. The script I had written extends UITiledSprite, and piggybacks on its Vertex Generation function OnFill(). It basically just let the UITiledSprite generate all the vertices, then applied a UV offset before returning them. Here's those old scripts: https://dl.dropbox.com/u/39656041/ScrollingTextures-NGUI.zip (https://dl.dropbox.com/u/39656041/ScrollingTextures-NGUI.zip)
Title: Re: Scrolling UV Animation
Post by: Marckeeling on February 21, 2014, 05:05:54 PM
Yeah i tried the scripts just a second ago, and with not much luck. The console wasn't too happy with me xD
It's all way over my head unfortunately.
Title: Re: Scrolling UV Animation
Post by: Marckeeling on February 21, 2014, 05:06:45 PM
Btw I was writing a post to say thank you for the help, but you guys are too quick for me :D
Title: Re: Scrolling UV Animation
Post by: Marckeeling on February 22, 2014, 11:13:51 AM
Been trying to get this feature to work all night xD could I possibly get some help from someone who understands this? Im worried its no longer possible and am considering frame animation to compensate. This will be far too slow though :S
Title: Re: Scrolling UV Animation
Post by: ArenMook on February 22, 2014, 11:23:27 AM
As I said... create a UITexture (ALT+SHIFT+T), assign your striped texture to it or whatever you want to scroll, and in your script modify the UITexture's UV rect.
Title: Re: Scrolling UV Animation
Post by: Marckeeling on February 22, 2014, 12:00:02 PM
OK, thank you for the support, It was the script writing part that i needed to avoid << smelly artist doesn't understand the use of public and private stuff...


I'll have to get help after the weekend then. Thanks anyway
Title: Re: Scrolling UV Animation
Post by: ArenMook on February 23, 2014, 10:48:53 AM
  1. using UnityEngine;
  2.  
  3. public class UVAnimation : MonoBehaviour
  4. {
  5.     public Vector2 animRate = new Vector2(1f, 0f);
  6.  
  7.     void Update()
  8.     {
  9.         UITexture tex = GetComponent<UITexture>();
  10.  
  11.         if (tex != null)
  12.         {
  13.             Rect rect = tex.uvRect;
  14.             rect.x += animRate.x * Time.deltaTime;
  15.             rect.y += animRate.y * Time.deltaTime;
  16.             tex.uvRect = rect;
  17.         }
  18.     }
  19. }
Title: Re: Scrolling UV Animation
Post by: Marckeeling on February 25, 2014, 04:24:28 AM
Thank you so much dude, christ this is the best support ive ever experienced. Congratz