It won’t let me use void for the OnGUI function. Why not. Plase help!
using UnityEngine;
using System.Collections;
public class playerHunger : MonoBehaviour{
public int maxHunger = 1000;
public int curHunger = 1000;
float lastTime;
public float hungerBarLength;
void Start () {
hungerBarLength = Screen.width / 4;
}
void Update () {
AdjustCurrentHunger (0);
if(Time.time > lastTime + 2){
lastTime = Time.time;
curHunger--;
}
//won't let me use void OnGUI! Why? Whats the fix
void OnGUI(){
GUI.Box (new Rect(5, 560, hungerBarLength, 20), "Hunger :" + curHunger + "/" + maxHunger);
}
public void AdjustCurrentHunger(int adj){
curHunger += adj;
if (curHunger < 0) {
curHunger = 0;
}
if (curHunger > maxHunger) {
curHunger = maxHunger;
}
hungerBarLength = Screen.width / 4 * (curHunger / (float)maxHunger);
}
}