There are many ways to make blood bars in unity, most with Ngui; here I'll talk about a simple method of making blood strips.
This blood bar production is not like Ngui, it is by a piece of code can be achieved, but looks less effective, or look at the code bar;
public texture2d bg; //the background of the blood bar, you need to drag and drop the assignment outside; public texture2d blood; //Blood Bar float Life=100; //Total health value; public transform m_transform; // A transform component of an object bound to a blood bar; void ongui () { vector3 headpos= Camera.main.WorldToScreenPoint (m_transform.position+vector3.up*2.5f); //converts a point on the object's head to screen coordinates; gui. Drawtexture (New rect (headpos.x-15,screen.height-headpos.y,100,3), BG); //the background of the blood bar is finished, the blood bar on the screen position gui. Drawtexture (New rect (headpos.x-15,screen.height-headpos.y,100*life/life,3), blood); // (HEADPOS.X-15,SCREEN.HEIGHT-HEADPOS.Y) //the Blood bar is 100 units long, 3 units wide, so you should read it.; //Current Health value/Total Health = current blood bar length/background length }
This will be OK, the code I am directly in the face of the writing, there is a wrong words welcome correction Oh!
This article is from the "51cto_king" blog, make sure to keep this source http://cjboking.blog.51cto.com/11020113/1784372
Simple strips of blood from unity