Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Circular Bar

$
0
0
Hi, I using AlphaCutoff shader to make my life bar circular. Its working half good - the texture disappears but it leaving black texture behind it. How can I change black to texture? Shader: Shader "Custom/LifeBar" { Properties { _MainTex ("Base (RGB) Transparency (A)", 2D) = "" {} _BackTex ("Texture", 2D) = "black" {} _Cutoff ("Alpha cutoff", Range (0, 1)) = 0.5 } SubShader { Tags {"RenderType" = "Transparent" "Queue" = "Transparent" "IgnoreProjector" = "True"} Pass{ AlphaTest Greater [_Cutoff] Material { Diffuse (1,1,1,1) Ambient (1,1,1,1) } Lighting On SetTexture [_MainTex] { combine texture * primary } } } } Script to draw bar: if (Event.current.type.Equals(EventType.Repaint)) { mat.SetFloat("_Cutoff", lifePerc); Graphics.DrawTexture(new Rect((Screen.width - Screen.width / 6) - 5, (Screen.height - Screen.width / 6) - 5, Screen.width / 6, Screen.width / 6), gradient, mat); }

Viewing all articles
Browse latest Browse all 171066


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>