- Home /
Can you tell unity to resize the Game window by a button press?
Hello, the reason I'm asking this is because I'm making a game where to user can resize the window by powers of what the screen was already at. an sample of would be in NES emulators you can resize the emulator to. well it starts at 256x240 and you can resize it to 256 + 256 so its like 512x240 and then resize it again, thats what I'm trying to get. any one know of a way to possibly do this?
using UnityEngine;
using System.Collections;
public class ResizeTest : MonoBehaviour
{
void OnGUI()
{
if (GUI.Button(new Rect(10, 10, 256, 32), "Resize Up"))
{
}
}
}
That don't work either :/
Answer by Firedan1176 · Feb 14, 2015 at 11:08 PM
You can use Screen.SetResolution().
if (GUI.Button(new Rect(10, 10, 256, 32), "Resize Up")) {
Screen.SetResolution(Screen.width + 256, Screen.height + 256);
}
Answer by CHPedersen · Feb 14, 2015 at 11:06 PM
You can set the window size programmatically using Screen.SetResolution. Perhaps that's what you're looking for?
Your answer
Follow this Question
Related Questions
Make area adapt to screen size 1 Answer
Can't work with screen.width / height 3 Answers
Getting Device Screen Height and width in inches 2 Answers
Screen.currentResolution = Null? 1 Answer