Game Development Reference
In-Depth Information
Setting the field of view
The field of view is a video setting that doesn't really affect performance that much,
but it is an option that many PC gamers like to modify. The field of view literally
means what it's called; it determines how big the view port is for the player to see
the game. It's measured by angle degrees and can also be measured vertically, ho-
rizontally, or diagonally. Typically, the field of view is measured diagonally for video
games.
Add this function to your script:
public void SetFOV(float newFOV)
{
Camera.main.fieldOfView = newFOV;
}
The way that cameras in Unity measure the field of view is by using a float variable.
So in the preceding function, we receive a float, which will be the new field of view. To
change the field of view, we find the main camera, access it's fieldofView prop-
erty, and assign it to the new field of the view variable.
Setting the resolution
Next, we'll allow the player to modify the resolution of the game as well as decide
whether the game will be full screen or windowed. Add this function to your script:
public void SetResolution(int Res, int Full)
{
bool fs = Convert.ToBoolean(Full);
switch(Res)
{
case 0:
Screen.SetResolution(1920, 1080, fs);
break;
case 1:
Search WWH ::




Custom Search