一.单行序列
1.需要一张动画序列帧图片.我在网上随便找了一张
2.源码
Shader "Custom/s4" {
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_CellAmount ("Cell Amount", float) = 0.0
_Speed ("Speed", Range(0.01, 32)) = 12
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
float _CellAmount;
float _Speed;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN,inout SurfaceOutput o)
{
float CurrentIndex = fmod(_Time.y*_Speed,_CellAmount);
//fmod是cg语言中的取余方法.因为要循环播放,CurrentIndex表示是当前播放到第几个动画,所以取余
CurrentIndex = ceil(CurrentIndex);//需要理解
float2