Author Topic: Scrolling UV Animation  (Read 5665 times)

Marckeeling

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Scrolling UV Animation
« 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrolling UV Animation
« Reply #1 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.

BeShifty

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 7
  • Posts: 52
    • View Profile
Re: Scrolling UV Animation
« Reply #2 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

Marckeeling

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Scrolling UV Animation
« Reply #3 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.

Marckeeling

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Scrolling UV Animation
« Reply #4 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

Marckeeling

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Scrolling UV Animation
« Reply #5 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrolling UV Animation
« Reply #6 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.

Marckeeling

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Scrolling UV Animation
« Reply #7 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrolling UV Animation
« Reply #8 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. }

Marckeeling

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Scrolling UV Animation
« Reply #9 on: February 25, 2014, 04:24:28 AM »
Thank you so much dude, christ this is the best support ive ever experienced. Congratz