GUILayout.Space() doesn't work with floats?

I think this must be a bug. It’s the kind of thing that makes me pull my hair out. In the example below, whoRect and tmpRect are both returned from GUILayoutUtility.GetLastRect(). My goal is to align text to columns based on the width of the column header such that text + space = width. I had planned on doing this by calling GUILayout.Space() but it doesn’t work with the results for GetLastRect() for some extremely odd and strange reason I cannot for the life of me fathom.

            // simplest test (this works)
            float x = 78f;
            float y = 23f;
            int diff = (int)(x - y); 
            GUILayout.Space(diff);

            // this doesn't
            x = whoRect.width;
            y = tmpRect.width;
            print("x " + x + " y " + y);  // 78 and 23
            diff = (int)(x - y);  // note: also tried with diff as a float
            print(diff); // 55
            GUILayout.Space(diff);

So when I use the difference from the two Rects I don’t get any space. The value prints out identically in the two calls to GUILayout.Space() so why does the first work and the latter not?

goes off and bangs head against wall some more

Let’s take a look at the documentation:

static function Space (pixels : float) : void

Pixels, the amount of space is measured in pixels and there is no thing as 1.5 pixel. It’s easy to miss this kind of stuff.

I’m pretty sure that’s more sequential problem. Where and when do you use GetLastRect? GetLastRect only returns in the Repaint event a meaningful value.during the layout step it’s garbage since the size of each rect can only determined at the end of the layout step.

So within the same OnGUI you can’t use a rect value within the layouting phase. We don’t know the rest of your script so we can’t say what you actually want to do…