- Home /
Question by
Lukamyte · Sep 15, 2013 at 01:53 AM ·
errorerror messagebox
GUI.Box error
I have some code for the HP box of the player, but there is an error.
function OnGUI() {
GUI.Box(Rect(0, 0, 10, 10), CurHp);
}
It's not all of it, just what's needed. The error Unity is insisting on is : No appropriate version of 'UnityEngine.GUI.Box' for the argument list '(UnityEngine.Rect, int)' was found.
Any help?
Comment
Best Answer
Answer by Eric5h5 · Sep 15, 2013 at 02:23 AM
As shown in the docs, the argument types you can use are String, GUIContent, and Texture. You should convert the int to a string for display, such as by using ToString. (Also, as a matter of style, use lowercase for variable names; it should be "curHp".)
Thanks, that fixes the error, but for some reason the GUI doesn't show up on the screen.