using UnityEngine;
using System.Collections;
public classtest : MonoBehaviour
{
int scrollSpeed;
int countX = 4;
int countY = 4;
private float offsetX = 0.0f;
private float offsetY = 0.0f;
private Vector2 singleTexSize;
void Start()
{
singleTexSize = new Vector2(1.0f / countX, 1.0f / countY);
GetComponent<Render>().material.mainTextureScale = singelTexSize;
}
void Update()
{
float frame = Mathf.Floor(Time.time * scrollSpeed);
offsetX = frame / offsetX;
offsetY = -(frame - frame % countX) / countY / countX;
GetComponent<Render>().material.setTextureOffset("_MainTex", new Vector2(offsetY, offsetX));
}
}
uv动画
最新推荐文章于 2024-04-16 12:24:34 发布