Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. public class PlayerStats : MonoBehaviour {
  2. float dispPlayerHealth;
  3. public Transform player;
  4. public Rect rectangle = new Rect(0,0,50,25);
  5. string boxText = string.Empty;
  6. void Update () {
  7.     Vector3 screenPosition = Camera.current.WorldToScreenPoint( player.position );
  8.     rectangle.x = screenPosition.x;
  9.     rectangle.y = screenPosition.y;
  10.     float playerHealthNow = GetComponent<MoveCharacter>().playerHealth;
  11.     if(dispPlayerHealth != playerHealthNow) { dispPlayerHealth = playerHealthNow; boxText = string.Format("{0:0}", dispPlayerHealth); }
  12. }
  13.  
  14. void OnGUI (){
  15.     GUI.Box(rectangle, boxText);
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement