港务部
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
798 B

using UnityEngine;
using System.Collections;
public class ScrollingUVs : MonoBehaviour
{
public int materialIndex = 0;
public Vector2 uvAnimationRate = new Vector2(0f, 0.5f);
public string textureName = "_BaseMap";
public bool ScrollBump = true;
public string bumpName = "_BumpMap";
Vector2 uvOffset = Vector2.zero;
void LateUpdate()
{
uvOffset += (uvAnimationRate * Time.deltaTime);
if (this.GetComponent<Renderer>().enabled)
{
this.GetComponent<Renderer>().materials[materialIndex].SetTextureOffset(textureName, uvOffset);
if (ScrollBump)
{
this.GetComponent<Renderer>().materials[materialIndex].SetTextureOffset(bumpName, uvOffset);
}
}
}
}