I need some help with this GUI code

Hello. I am using this bit of code to scale the GUI elements in my game(I placed the GUI stuff using absolute pixel positions). I am having some problems with it. First, I am getting this error “Ignoring invalid matrix assinged to GUI.matrix - the matrix needs to be invertible. Did you scale by 0 on Z-axis?”. Second, even though some of the GUI elements appear to scaling properly, when I click on some of the space in buttons, they do not work(this is related to the resolution, as the buttons work fine normally).

GUI.matrix = Matrix4x4.Scale(Vector3( parseFloat(Screen.width)  / 972, parseFloat(Screen.height) / 636));

Thanks

Make the 972 and the 636 float values too. Such as:

var w:float = 972;
var h:float = 636;

GUI.matrix = Matrix4x4.Scale(Vector3( parseFloat(Screen.width)/w, parseFloat(Screen.height)/h));

As for the button offset, I’m having the same problem.

It seems that the mouse is reading the y-value of where they button should be, and not the new scaled location. The buttons work fine when the game is at the specified resolution, but if the game is played at a smaller resolution, the y-value is below the button and if the resolution is larger, the y-value is above the button. I’ve been playing around with getting the y-mouse value to scale based on the resolution, but I’m at a loss.

Any help solving that problem would be appreciated.