x


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

more ▼

asked Dec 08 '10 at 11:01 AM

raul corrales gravatar image

raul corrales
268 25 28 34

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Dec 08 '10 at 11:48 AM

Proclyon gravatar image

Proclyon
1.4k 10 13 32

very thanks you

Dec 08 '10 at 11:57 AM raul corrales
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3885
x501
x394
x389

asked: Dec 08 '10 at 11:01 AM

Seen: 5083 times

Last Updated: Dec 08 '10 at 11:01 AM