GUI messes up depending on the screen resolution

I dont know why this happens but all my GUI texts, GUI textures etc are not where they are supposed to be when I change the screen resolution to something other than my default screen resolution. How do I fix this?

Please use search. This has been asker and answered a LOT of times before. Basically, instead of of setting the positions with an exact number like so

Gui.Button( Rect( x, y, width, height), text);

Make it relative to the default resolution. With default I mean the one you use to design it.

var defWidth : int;
var defHeight : int;

function OnGUI () {

    var widthScale = Screen.width/defWidth;
    var heightScale = Screen.height/defHeight;

    Gui.Button( Rect( x*widthScale , y*heightScale , width*widthScale , height*heightScale ), text);

}