I've been trying to make a *circular health bar*. Now, there's a tutorial out there that uses the cutout shader to create one.
My problem is: *The health bar is supposed to be semi transparent.*
So I looked for addon shaders because as far as I can see, there's no solution to that built in to Unity - needless to say, I didn't find any.
I tried writing my own, using the script reference to manage, sadly this one only works on straight bars (also, only really badly since its my first...)
So, my question is really: Can this shader somehow be salvaged to work in a circular manner? Or, even better, does anyone know a Shader with a Transparent Base Texture that also allows a seperate texture for cutouts?
Shader "Transparent/Bar" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Fill ("Fill Percentage", Range(-1.0,1.0)) = 0.5
_BarSz ("Bar Size", Float) = 3.0
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
Cull Off
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
fixed4 _Color;
float _Fill;
float _BarSz;
struct Input {
float2 uv_MainTex;
float3 worldPos;
};
void surf (Input IN, inout SurfaceOutput o) {
float p = _BarSz * _Fill;
clip(IN.worldPos.x + p);
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Transparent/VertexLit"
}
Thanks in advance!
↧