Trying to venture into UnityGUI here and I’m trying to attempt a Healthbar similar to the Old Mega-Man X.
http://remyvanruiten.files.wordpress.com/2013/01/full-health.png
^^For those who don’t know what it is^^
No-matter what I try, the sprite is always drawn in the middle of the box.
using UnityEngine;
using System.Collections;
public class GUIManager : MonoBehaviour
{
public Texture aTexture;
private float maxHealth;
private float currHealth;
private float TopHUDHeight = 608;
private float HUDHeight = 162;
void Start()
{
maxHealth = 100f;
currHealth = maxHealth;
aTexture.wrapMode = TextureWrapMode.Repeat;
}
void Update()
{
currHealth = 100f;
}
void OnGUI()
{
GUI.Box(new Rect(0, TopHUDHeight, Screen.width, HUDHeight), "");
GUI.Box (new Rect(0, TopHUDHeight, 240, HUDHeight), "Inventory/Money");
GUI.Box (new Rect(241, TopHUDHeight,25, HUDHeight), "H
E
A
L
T
H");
GUILayout.BeginVertical();
GUI.DrawTexture(new Rect(241, TopHUDHeight, 25, HUDHeight), aTexture, ScaleMode.ScaleToFit);
GUILayout.EndVertical();
GUI.Box (new Rect(267, TopHUDHeight, 490, HUDHeight), “Chat”);
GUI.Box (new Rect(758,TopHUDHeight,25, HUDHeight), “E
X
P”);
GUI.Box (new Rect(784, TopHUDHeight, 240, HUDHeight), “Gun/Ammo”);
}
}