Como de costumbre, anteponga el efecto.
código de sombreador:
Shader "Hidden/Loading"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Radiu("Radiu",Range(0.01,0.5)) = 0.25
_Width("Width",Range(0.01,0.5)) = 0.1
_RotSpeed("RotSpeed",Range(1,10)) = 5
_Color1("Color1",Color) = (1,1,1,1)
_Color2("Color2",Color) = (1,1,1,1)
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define PI 3.1415926
#define edge 4 / min(_ScreenParams.x,_ScreenParams.y)
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
fixed _Radiu;
fixed _Width;
fixed _Ctrl;
fixed _RotSpeed;
fixed4 _Color1;
fixed4 _Color2;
fixed4 frag (v2f i) : SV_Target
{
//重置坐标
fixed2 uv1 = i.uv - 0.5;
fixed angle = _Time.y * _RotSpeed;
//旋转
uv1 = mul(uv1,float2x2(cos(angle),sin(angle),-sin(angle),cos(angle)));
//计算反正切 然后设置0~1
fixed a1 = atan2(uv1.x,uv1.y);
a1 = (1 + a1 / PI) * .5;
//计算颜色
fixed4 c = lerp(_Color1, _Color2, a1);
//缓动效果
_Ctrl = lerp(0.3,0.8,((sin(_Time.y * _RotSpeed * 0.4) + 1) * 0.5));
a1 = step(a1,_Ctrl);
//圆环
fixed ring = (1 - smoothstep(_Radiu,_Radiu + edge,length(uv1))) * (smoothstep(_Radiu-_Width-edge,_Radiu-_Width,length(uv1)));
return c * a1 * ring;
}
ENDCG
}
}
}