標籤:uva scroll com nsf date cto atime one get
using UnityEngine;
using System.Collections;
public class ScrollBehaviour : MonoBehaviour
{
public int materialIndex;
public string textureName = "_MainTex";
public Vector2 uvAnimationRate = new Vector2(1f, 0f);
private Vector2 uvOffset = Vector2.zero;
private Material mat;
private Color col;
private float colorAhpha=0;
private void Start()
{
col = new Color(0.54f,0.45f,0.25f, colorAhpha);
mat = gameObject.transform.GetComponent<Renderer>().material;
}
private void LateUpdate()
{
if (colorAhpha <= 0.45f)
{
colorAhpha = colorAhpha + 0.001f;
col.a = colorAhpha;
mat.SetColor("_TintColor", col);
}
uvOffset += (Vector2)(uvAnimationRate * Time.deltaTime);
if (base.GetComponent<Renderer>().enabled)
{
base.GetComponent<Renderer>().materials[materialIndex].SetTextureOffset(textureName, uvOffset);
}
}
}
材質漸層出現及UV移動