Hello, I’l currently making a 2D Game and I need to let the rainbow powerup work, it needs to have a opacity of 50% overlay and needs to flash from left to right with Red, Orange, Yellow, Green, Cyan, Blue an Purple. Now I’ve tried many scripts, but I deleted them all because they didn’t work out for me ;(
Can someone please help me???
The rainbow gradient as seen in this picture:
Create a rainbow texture. This texture can be very small (height 1px, width: one pixel per color (red, yellow, green, blue, red), just make sure to use bilinear filtering.
Add screen overlay image effect on your camera, assign your rainbow texture.
If you want some very specific blending function, you can still write your own image effect / shader, but i believe this builtin will be enough for you
Forgot about the scrolling (flashing?) part.
Provided you don’t need to control the flash/scroll position exactly, the easiest way would be to just modify the shader.
Duplicate the default shader (BlendModesOverlay, btw all these are in the Effects standard unity package). Then find the vertex shader and add scrolling of position using the lbuiltin shader value _Time. So: Just declare
float _Time; above the vertex shader function (unity finds and fills the value automatically). Then, at the end of the shader, add this time value to uv.x; For example, jsut before returning, add line
o.uv.x += _Time*scrollSpeed , replacing scrollSpeed with whatever number you want (start with 1)
Use this shader in the screen overlay component.