Hello! In unity the resolution is set to 1366x768 and the GUI etc are all in place, the problem appears when I publish it for web. The resolution seems to automaticly set itself to 1600x900 (I believe this is the resolution after testing that resolution in the game room of Unity). When the game is running in 1600x900 the GUI doesn't fit where it is suppose too! The GUI doesn't seem to rescale/move if I make the web window smaller/larger. Any ideas how I can fix it so the resolution is set to 1366x768 ? Thanks! I have changed the resolution inside of build/player settings to 1366x768 by the way, no luck. After some testing.. it seems that everything in game is scaling with resolution, but not my GUI scripted stuff, any ideas how to easliy make everything scale well without having to rescript all position? /screen_width ?
Never tried it, could that be a good solution? Have to read about it first as well, never heard of it to be honest
To be honest I don't know all the things that can be done with matrix, but here is an example of one. GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity,Vector3 (Screen.width / 1024.0, Screen.height / 768.0, 1)); Just place it first in the OnGui() function. Hope this helps.
so basically you have that in your void OnGUI and it should work right away? I get some errors thought ( if it was correct to put it into OnGUI). By the way I see it says vector3, but I do that really matter even if my game is 2D? Errors:
You may have to c# the example. There shouldn't be any problems with a 2D game, though I never tested a matrix in one.
Solution: Code (CSharp): void OnGUI() { AutoResize(1366, 768); } Code (CSharp): public static void AutoResize(int screenWidth, int screenHeight) { Vector2 resizeRatio = new Vector2((float)Screen.width / screenWidth, (float)Screen.height / screenHeight); GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(resizeRatio.x, resizeRatio.y, 1.0f)); }