unity UV 动画
生活随笔
收集整理的這篇文章主要介紹了
unity UV 动画
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
using UnityEngine;
using System.Collections;public class UV_Animation : MonoBehaviour {public float _columnCount=1;//行數public float _rowCount=1;//列數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));//計算行列位置_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);}
}
?
轉載于:https://www.cnblogs.com/sy88/p/3436704.html
總結
以上是生活随笔為你收集整理的unity UV 动画的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: shopex还是ecshop
- 下一篇: java List及其实现类