UGUI streamer effects
Renderings:
principle
1. Write a simple Shader:
float4 frag (v2f i) : SV_Target
{
float4 col = tex2D(_MainTex, i.uv);
float2 uv = i.uv - 0.5;
float2 pt = pointbyangle( fmod( _StartAngle + _Time.y * _Speed, 360));
float l = clamp( 1 - length( uv - pt ) / ( _Size * 1.414213562373), 0, 1 );
float4 bor = lerp( _BorderColor, _BorderColor * col.a, _Alpha );
return lerp( float4(0,0,0,0), bor, l );
}
2. Create a material and assign it to the Image
Items that can be configured for the material include streamer color, streamer position, speed, size, and start angle (this is to prevent all streamers from being synchronized when multiple UI components have this special effect. After the start angle is given, each form can be disrupted. streamer angle, making them each different).
pits to watch out for
To make PostProcess work on UGUI, the Canvas rendering mode cannot be set to Overlay, and the other two modes are fine. If the UI only needs to be placed on the screen, use Camera mode. If the UI needs to be placed in the scene, then World Space model.
Source code download:
https://download.csdn.net/download/sdhexu/21540738