直接上源码,需要的自取,通过更改X,Y来改变方向及速度
第一种:
Shader "UI/Flow UV" {
Properties{
_MainTex("Base (RGB)", 2D) = "white" {}
_MainTint("Diffuse Tint", Color) = (1, 1, 1, 1)
// 通过调整正负及值来改变方向与速度
_ScrollXSpeed("XSpeed", Range(-10, 50)) = -1
_ScrollYSpeed("YSpeed", Range(-10, 50)) = 15
}
SubShader{
Tags{ "RenderType" = "Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
float _ScrollXSpeed;
float _ScrollYSpeed;
fixed4 _MainTint;
struct Input {
float2 uv_MainTex;
};
void surf(Input IN, inout SurfaceOutput o)
{
fixed2 scrolledUV = IN.uv_MainTex;
fixed xScrollOffset = _ScrollXSpeed * _Time;
fixed yScrollOffset = _ScrollYSpeed * _Time;
scrolledUV += fixed2(xScrollOffset,yScrollOffset);
half4 c = tex2D(_MainTex, sc