Hi, I got this UV scroller off the wiki, I'm wondering if someone knows how to modify it so that it has a step function, able the modify the distance and frequency of each step. I'm expirimenting with a light border around a sign like this.
Thanks!
Hi, I got this UV scroller off the wiki, I'm wondering if someone knows how to modify it so that it has a step function, able the modify the distance and frequency of each step. I'm expirimenting with a light border around a sign like this.
Thanks!
You can do something like this:
uvOffset += 1/LinesNumber;
Assuming that every line is the same height.
Try this code. It will update uv with uvAnimationRate every uvAnimationTimestep.
using UnityEngine;
using System.Collections;
public class ScrollingStepUVs : MonoBehaviour
{
public int materialIndex = 0;
public float uvAnimationTimestep = 1.0f;
public Vector2 uvAnimationRate = new Vector2( 0.1f, 0.0f );
public string textureName = "_MainTex";
Vector2 uvOffset = Vector2.zero;
void Start()
{
InvokeRepeating("UpdateUV", uvAnimationTimestep, uvAnimationTimestep);
}
void UpdateUV()
{
uvOffset += uvAnimationRate;
if( renderer.enabled )
{
renderer.materials[ materialIndex ].SetTextureOffset( textureName, uvOffset );
}
}
}