- Home /
Question by
levan1 · Dec 08, 2014 at 06:24 PM ·
resolutionfixfixed
Fixed game resolution
Hello, My game default resolution is 700x500 in the webplayer. I want this resolution to be fixed, in case of changing resolution, the game not be started. How can I do this?
Comment
Best Answer
Answer by static_cast · Dec 08, 2014 at 11:18 PM
How about this?:
Vector2 targetResolution;
void Start()
{
targetResolution = new Vector2(700, 500);
}
Update()
{
if(Screen.width != (int)targetResolution || Screen.height != (int)targetResolution)
{
//WRITE GUI MESSAGE HERE AND QUIT GAME [or whatever you want to do]
//Do something like... Application.Quit();
}
}
Thank you for the response, shall i attach this script to the main camera?
void Update ()
{
if(Screen.width != (int)targetResolution.x || Screen.height != (int)targetResolution.y)
{
Application.LoadLevel("$$anonymous$$ain$$anonymous$$enu");
}
}
No problem. I haven't logged in to unity answers for a while, sorry about that.
It doesn't matter where you attach the script, but attach it to something you know will stay in the game forever [ie empty gameobject that handle game stuff]
Your answer
Follow this Question
Related Questions
Need help fixing my GUI 1 Answer
Set GUI buttons and GUITextures in fixed place 2 Answers
Is that a resolution-related issue? 1 Answer
Keep sprites at fixed size 3 Answers