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

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