【原】UV动画

来源:互联网 发布:淘宝网店财务个人总结 编辑:程序博客网 时间:2024/04/29 02:03
using UnityEngine;
using System.Collections;
using System;

public class OffsetTexs : MonoBehaviour
{
    public int scrollSpeed=5;
    public int countX=4;
    public int countY=4;

    private float offsetX=0.0f;
    private float offsetY=0.0f;
    private Vector2 singleTexSize;

// Use this for initialization
void Start () {
        singleTexSize=new Vector2(1.0f/countX,1.0f/countY);
        renderer.material.mainTextureScale=singleTexSize;
}
// Update is called once per frame
void Update () {
        float frame=Mathf.Floor(Time.time*scrollSpeed);
        offsetX=frame/countX;
        offsetY=-(frame-frame%countX)/countY/countX;
        renderer.material.SetTextureOffset("_MainTex",new Vector2(offsetX,offsetY));
}
}
原创粉丝点击