Shader "Custom/Simple" { Properties { _Color("Base Color", Color) = (1,1,1,1) _MainTex("Base(RGB)", 2D) = "white" {} _RSpeed("RotateSpeed", Range(1, 100)) = 30 } SubShader { tags{"Queue" = "Transparent" "RenderType" = "Transparent" "IgnoreProjector" = "True"} Blend SrcAlpha OneMinusSrcAlpha Pass { Name "Simple" Cull off CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" float4 _Color; sampler2D _MainTex; float _RSpeed; struct v2f { float4 pos:POSITION; float4 uv:TEXCOORD0; }; v2f vert(appdata_base v) { v2f o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv = v.texcoord; return o; } half4 frag(v2f i):COLOR { float2 uv = i.uv.xy - float2(0.5, 0.5);//将旋转点从左上角唯一到中心点(UV默认中(0,0)点为左上角) uv = float2(uv.x * cos(_RSpeed * _Time.w) - uv.y * sin(_RSpeed * _Time.w), uv.x * sin(_RSpeed * _Time.w) + uv.y * cos(_RSpeed * _Time.w));//计算旋转,矩阵乘法 uv += float2(0.5, 0.5); half4 c = tex2D(_MainTex , uv) * _Color;//以UV为坐标取得纹理_MainTex对应位置的像素内容。 return c; } ENDCG } } }