Change GUI Value with Variable

Hey guys. Me again. I made this script a while ago and I can’t seem to get the location in the screen right. I am new at scripting and I’m only now starting to get it all down. Can someone review this and tell me what I did wrong? Thanks to anyone who helps.

  • Cody
    var labelWidth : int;
    var labelHeight : int;

    function OnGUI () {
    GUI.Box (Rect (labelWidth.width, labelHeight.height,300,25), “Press the ‘m’ key to toggle mouse visibility”); // Draws a box with text

Also I don’t know why its coming out all ugly in this question But it is formatted properly. Thanks.


It looks like you’re trying to access .width and .height properties of an int (which most likely does not contain those properties.

Try changing your code to simply Rect(labelWidth, labelHeight, 300, 25);

Keeping in mind that those two positions in the Rect() actually refer to the position for X and Y, not the actual width and height, but I guess that’s just a variable naming issues.