I’m trying to create a health-bar similar to that found on the hit-game “Mega-Man X”
^^^ For those of you who don’t know what this is ^^^
I was told in the Unity3D Answers to use the WrapMode.Repeart for the Texture, although this isn’t working
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\nE\nA\nL\nT\nH");
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\nX\nP");
GUI.Box (new Rect(784, TopHUDHeight, 240, HUDHeight), "Gun/Ammo");
}
}
You see what I’m trying to do, it’s not working. (it’s onyl drawing the sprite once, in the middle of the rectangle.
Halp?
The texture is a 25x10 sprite.
— Please note, this is not my true game CS file, just trying to get a layout for my GUI