unity UV 动画
生活随笔
收集整理的這篇文章主要介紹了
unity UV 动画
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
using UnityEngine;
using System.Collections;public class UV_Animation : MonoBehaviour {public float _columnCount=1;//行數(shù)public float _rowCount=1;//列數(shù)public int _framePerSecond;//幀速率float _colIndex=0;float _rowIndex=0;bool _isPlay=false;float myTime=0;// Use this for initializationvoid Start () {_rowIndex=_rowCount-1;}// Update is called once per framevoid Update () {//改變幀速率myTime+=Time.deltaTime;_colIndex=Mathf.Floor(myTime*(_framePerSecond-1));//計(jì)算行列位置_colIndex=_colIndex%_columnCount;if(_colIndex!=0){_isPlay=true;}if(_isPlay){if(_colIndex==0){_rowIndex--;Debug.Log("1="+_rowIndex);if(_rowIndex==-1){_rowIndex=_rowCount-1;}_isPlay=false;}}//改變貼圖uv值renderer.material.mainTextureScale=new Vector2 (1/_columnCount,1/_rowCount);renderer.material.mainTextureOffset=new Vector2(1/_columnCount*_colIndex,1/_rowCount*_rowIndex);}
}
?
轉(zhuǎn)載于:https://www.cnblogs.com/sy88/p/3436704.html
總結(jié)
以上是生活随笔為你收集整理的unity UV 动画的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: shopex还是ecshop
- 下一篇: java List及其实现类