Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PlayerStats : MonoBehaviour {
- float dispPlayerHealth;
- public Transform player;
- public Rect rectangle = new Rect(0,0,50,25);
- string boxText = string.Empty;
- void Update () {
- Vector3 screenPosition = Camera.current.WorldToScreenPoint( player.position );
- rectangle.x = screenPosition.x;
- rectangle.y = screenPosition.y;
- float playerHealthNow = GetComponent<MoveCharacter>().playerHealth;
- if(dispPlayerHealth != playerHealthNow) { dispPlayerHealth = playerHealthNow; boxText = string.Format("{0:0}", dispPlayerHealth); }
- }
- void OnGUI (){
- GUI.Box(rectangle, boxText);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement