ProgressBar

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Instructions)
(Instructions)
Line 23: Line 23:
 
*Create a material with the shader being "Transparent Cutout Vertex Lit"
 
*Create a material with the shader being "Transparent Cutout Vertex Lit"
 
*Use progress texture in the material  
 
*Use progress texture in the material  
*Use code above, or something like it in a script.
+
*Use code above, or something like it in a script, attach it to the Quad/Sprite.
 +
*2D Only - Use material and set it on the sprite, remember it'll ignore all but the size of the sprite.
 +
*REMEMBER - This is using a cutout shader, so you'll need something behind it if you want it coloured.
  
 
== Resources ==
 
== Resources ==
  
 
[http://wiki.unity3d.com/index.php/File:Trans-slider-2.png Transparent Progress Bar Slider]
 
[http://wiki.unity3d.com/index.php/File:Trans-slider-2.png Transparent Progress Bar Slider]

Revision as of 01:11, 17 February 2014

Contents

What is it

A simple circular progress bar for 2D Sprites, or on a 3D quad.

Demo

http://www.youtube.com/watch?v=y8RLVuoq0AU

Code

void Update() {
	float revealOffset = (float)(Time.timeSinceLevelLoad % 10) / 10.1F; 
 
	gameObject.renderer.material.SetFloat ("_Cutoff", revealOffset);
}

Instructions

  • Create your circular progress bar image with an alpha gradient (N.B. it can be ANY shape)
  • Set the import to be a texture (not a sprite) and DO NOT USE COMPRESSION.
  • Create a material with the shader being "Transparent Cutout Vertex Lit"
  • Use progress texture in the material
  • Use code above, or something like it in a script, attach it to the Quad/Sprite.
  • 2D Only - Use material and set it on the sprite, remember it'll ignore all but the size of the sprite.
  • REMEMBER - This is using a cutout shader, so you'll need something behind it if you want it coloured.

Resources

Transparent Progress Bar Slider

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox