I was wondering how I would automatically re size the window so that it fits in the screen... I have a large computer, but my friends (and a lot of other people) have laptops and the buttons and text run off the screen! Is there a way to re size the screen, depending on the screens maximum size, so that they can see everything I see... Any Help Is Appreciated!
this maximises the unity application and sets the resolution to the current desktop resolution.
Screen.currentResolution returns the current desktop resolution of the machine.
true/false sets the fullScreen state.
you can then go back to windowed with:
Screen.SetResolution (1024, 768, false); //enter you desired resolution
To switch between fullScreen and not only you can use:
Screen.fullScreen = true/false;
[EDIT 1] To make sure that your GUI resizes to the new resolution:
function OnGUI()
{
var oldMatrix : Matrix4x4;
var tMatrix : Matrix4x4;
var width : int = 1024; //Reference resolution
var height : int = 768; //Reference resolution
oldMatrix = GUI.matrix; //Store current matrix
tMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3(1.0*Screen.width/width, 1.0*Screen.height/height, 1.0)); //Construct matrix to scale to actual view size
GUI.matrix = tMatrix; //Set the GUI matrix to the scaling matrix
drawYourGUIElementsToSuitReferenceResolution(); //as the function says;)
GUI.matrix = oldMatrix //Set the original matrix back
}
Are you talking about the window itself being larger than the screens, or are you talking about the resolution being reduced but all your 2D GUI stuff being off screen?
If it's the latter, you'll have to use some special code to make your UnityGUI stuff resolution independent.