思路
1、生成圆环
2、圆环的色带有渐变(从里到外Alpha:0-1)
3、随时间移动
4、调速度
5、变颜色
6、圆环宽度可调(0-1)
Shader代码
Shader "Custom/AttackCircle"
{
Properties{
_Color("Color", Color) = (1,1,1,1)
_Speed("Speed",Range(0,5)) = 1
_Width("Width",Range(0,1)) = 0.1
}
SubShader{
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha:fade
fixed4 _Color;
float _Speed;
float _Width;
struct Input {
float2 uv_MainTex;
};
void surf(Input IN, inout SurfaceOutput o)
{
float2 tep = IN.uv_MainTex;
tep.x -= 0.5;
tep.y -= 0.5;
float dis = sqrt(tep.x * tep.x + tep.y * tep.y);
float d = tan(_Time.y*_Speed) - _Width/2.0;
float d1 = d + _Width / 2.0;
o.Emission = _Color;
if (dis > d && dis < d1)
{
float d2 = dis - d;
o.Alpha = d2 / _Width;
}
else
{
o.Alpha = 0;
}
}
ENDCG
}
}