In case anyone’s looking to do the good old alpha healthbar trick with the new sprite system, I’ve whipped this one up quickly. The alpha channel of your sprite is used to determine what to show and fills that with the Tint color.
Unfortunately I tried this shader and all I see is the pink “something is wrong” look on anything I apply it to. I’m currently using an Alpha cutoff shader I hacked together with little knowledge of shader programming, but I’d like something that allows me to change the tint color!
Hey MABManZ, I wrote the shader for the new Unity 2D Sprites; it’s not intended to be used on other objects due to how Unity’s new sprite system works. There should be various other shaders on this forum allowing you to do that:
Is there any way to add partial transparency as well, so the health-bar is see-through? I’d like alpha clipping with a constant Opacity parameter to set object transparency when the clipped graphic is drawn.
After a lot of chasing information (documentation in this field is the suckiest yet for Unity, which otherwise has been very good), I’ve created a suitable shader for my needs. Very easy once you know what Clip() does (explained in HLSL documentation, not Unity docs).
The shader has independent properties for cutoff threshold and final alpha value.