- Home /
how I can change the screen resolution in real time?
how I can change the screen resolution in real time?
i want put this:
Screen.SetResolution (640.480, false);
But where I put it?
Thanks in advance
Answer by Proclyon · Dec 08, 2010 at 11:48 AM
There are many options.
Here's an idea:
Make a script JS/C# it doesn't matter right now which.
Attach the script to an object that you can send input with the input manager.
Make a method that responds to input.
Set the value of the screen when the input matches that of the requirement for the method 'somekey'
potentially you may want to have two public floats so you can change the values to (x,y) instead of your hardcoded (640,480). Having them public means you can change it quite easily in the inspector ( and it matters for inheritance , proper design and code safety , but I don't think you really need to know that right now for this question so if you don't know what it is just forget about it for the moment and assume public just let's you change it in the editor)
So then the fields of the class and body of the change method would become:
//two variables with poorly chosen names for the resolution var x : float; var y : float;
function Update() { //Updates the input every frame UpdateInput(); }
function UpdateInput() { //Your input reading code here }
function SetResolution(x,y) //The parameters for the set resolution method { //Sets the resolution of the screen to x y Screen.SetResolution (x,y, false); }
Sorry if the code isn't that great, I had to look up most of the syntax since I don't understand JS that much, just C#. I hope this shows the general outline of such a script. Getting inputhandling done is something you should be able to do (yes even if you are not a programmer!) , but that is just my opinion
Your answer
Follow this Question
Related Questions
Which Is The Actual Game?(Max or no Max Screen) 1 Answer
How to call Screen.SetResolution() only once before the first scene starts loading ? 1 Answer
Position GameObject to Bottom Left Corner 2 Answers
How to make game recognise Screen resolution on startup 1 Answer
Where is Screen.Resolutions stored? 2 Answers