What's wrong in OnGUI?

Ok, so on one script I use

var currentSanity : float = 0.0;
var maxSanity : float = 100.0;
var minSanity : float = 0.0;
function OnGUI()
{
    GUI.Box(Rect(5,5,55,25), "Insanity");
    GUI.Box(Rect(60,5,55,25), currentSanity.ToString("0") + "/" + maxSanity);
}

and on another I use

var timeGoing : float = 0.0;
function OnGUI()
{
    GUI.Box(Rect(120,5,55,25), timeGoing);
}

The top one works, the second one doesn’t. It tells me that (UnityEngine.Rect, float) is a bad argument for UnityEngine.GUI.Box. Can anyone tell me how to fix this and make it work?

in the top example, your arguments are Rect() and String

in the bottom example, your arguments are Rect() and float

My guess is that GUI.Box takes in only Rect() and String. so you have to convert your “timeGoing” float into a string. like what you did in the top with “currentSanity”

lists all the permitted variants at the top

Ok, I guess you can add floats as strings as long as you use a string to begin with, Thanks.