- Home /
Taking the user's screen resolution before running a GUI.matrix?
Okay, I'm fairly new to GUIs, so correct me if I'm wrong.
- I can just use Screen.width and Screen.height, but without a matrix images will be stretched. 
- To keep things in a good ratio, you use a GUI.matrix. 
- The GUI.matrix needs the native resolution of the user to function properly. 
So how can I take their native resolution and then plug those numbers into my matrix? Here is my code, just using my own native resolution (the relevant parts):
var nativeVerticalResolution = 1050.0; var nativeHorizontalResolution = 1680.0;
 
               GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, Vector3 (Screen.width / nativeHorizontalResolution, Screen.height / nativeVerticalResolution, 1));
 GUI.Label(Rect ((nativeHorizontalResolution / 2) - (image.width / 2), 0, image.width, image.height), image); 
This puts my image at the (center / top) of the screen and works great on my resolution. But it won't work as well on another resolution, I know because I wasted a ton of time when I had the nativeVerticalResolution set wrong. 
Seems like at the moment I've set it up great to scale on any ratio I use on my computer, but I want it to work on any computer I move it to. Any solutions, or maybe I'm going about this the wrong way?
Thanks in advance!
I'm watching this myself as I cant even get GUI.matrix to parse without the error asking if I scaled Z by zero, and I have literally the same code as you.
Your answer
 
 
             Follow this Question
Related Questions
Is that a resolution-related issue? 1 Answer
Screen Resolution and GUI cutoff issue. Android. 1 Answer
Resolution & aspect ratio GUI 1 Answer
Cannot see full view of Screen in Unity preview 2 Answers
Button and resolution problem 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                