Screen.SetResolution not working properly

Hello All! I am having an Issue in Unity 5.2. I am creating a settings menu for my game and there will be an option to change the resolution. I coded the Buttons, and I can confirm that they press. But I see no Resolution change when I click the button. Here is the code:

@script ExecuteInEditMode() 

var menu = true;
var options = false;
var sound = false;
var video = false;

var sfxVol : int = 6;
var musicVol : int = 6;

var fieldOfView : int = 80;

var fullscreen : boolean = false;


function OnGUI () {

if(menu){


if (GUI.Button(Rect(Screen.width/2 - 50, Screen.height/2, 100, 30), "Start Game")){
Application.LoadLevel(1);

// play game
}


if (GUI.Button(Rect(Screen.width/2 - 50, Screen.height/2 + 30, 100, 30), "Options")){


menu = false;
options = true;
}


if (GUI.Button(Rect(Screen.width/2 - 50, Screen.height/2 + 90, 100, 30), "Quit")){


Application.Quit();
}
}


if(options){


if (GUI.Button(Rect(Screen.width/2 - 50, Screen.height/2, 100, 30), "Audio Settings")){


options = false;
sound = true;
}


if (GUI.Button(Rect(Screen.width/2 - 50, Screen.height/2 + 30, 100, 30), "Video Settings")){


options = false;
video = true;
}


if (GUI.Button(Rect(Screen.width/2 - 50, Screen.height/2 + 90, 100, 30), "Back")){


options = false;
menu = true;
}
}


if(sound){

sfxVol = GUI.HorizontalSlider (Rect (Screen.width/2 - 50, Screen.height/2, 100, 30), sfxVol, 0.0, 10.0);
GUI.Label(Rect(Screen.width/2 - 50 + 110, Screen.height/2 - 5, 100, 30), "SFX: " + sfxVol);

musicVol = GUI.HorizontalSlider (Rect (Screen.width/2 - 50, Screen.height/2 + 30, 100, 30), musicVol, 0.0, 10.0);
GUI.Label(Rect(Screen.width/2 - 50 + 110, Screen.height/2 + 25, 100, 30), "Music: " + musicVol);

if (GUI.Button(Rect(Screen.width/2 - 50, Screen.height/2 + 90, 100, 30), "Back")){


sound = false;
options = true;
}
}


if(video){

var qualities = QualitySettings.names;

GUILayout.BeginVertical ();

for (var i = 0; i < qualities.Length; i++){


if (GUI.Button(Rect(Screen.width/2 - 50,  Screen.height/2 - 120 + i * 30, 100, 30), qualities*)){*

QualitySettings.SetQualityLevel (i, true);
}
}

GUILayout.EndVertical ();

fieldOfView = GUI.HorizontalSlider (Rect (Screen.width/2 - 50,Screen.height/2 - 150,100,20), fieldOfView, 30, 120);
GUI.Label(Rect(Screen.width/2 - 50 + 110, Screen.height/2 - 155, 100, 30), "FOV: " + fieldOfView);
//640x360
if(GUI.Button(new Rect(Screen.width/2 - 160, Screen.height/2 + 130, 100, 30), “360p”)) {
Screen.SetResolution(640, 360, fullscreen, 0);
Debug.Log(“Resolution set to 640x360”);
}
//1280x720
if(GUI.Button(new Rect(Screen.width/2 - 50, Screen.height/2 + 130, 100, 30), “720p”)) {
Screen.SetResolution(1280, 720, fullscreen, 0);
Debug.Log(“Resolution set to 1280x720”);
}
//1920x1080
if(GUI.Button(new Rect(Screen.width/2 + 60, Screen.height/2 + 130, 100, 30), “1080p”)) {
Screen.SetResolution(1920, 1080, fullscreen, 0);
Debug.Log(“Resolution set to 1920x1080”);
}
if(GUI.Button(new Rect(Screen.width/2 - 110, Screen.height/2 + 160, 100, 30), “Fullscreen”)) {
fullscreen = true;
}
if(GUI.Button(new Rect(Screen.width/2 + 10, Screen.height/2 + 160, 100, 30), “Windowed”)) {
fullscreen = false;
}

if (GUI.Button(Rect(Screen.width/2 - 50, Screen.height/2 + 90, 100, 30), “Back”)){

video = false;
options = true;
}
}
}
It is in JS. I used a pre-made C# Script that let you change the resolution, And I noticed a big change when choosing a lower res. This is the other script:
using UnityEngine;
using System.Collections;

public class MainMenu : MonoBehaviour {

  • private bool showOptions = false;*

  • public float shadowDrawDistance;*

  • public int ResX;*

  • public int ResY;*

  • public bool Fullscreen;*

  • // Use this for initialization*

  • void Start () {*

  •  showOptions = false;*
    
  • }*

  • // Update is called once per frame*

  • void Update () {*

  • }*

  • void OnGUI() {*

  •  if(GUI.Button(new Rect(500, 100, 300, 100), "Start Game")) {*
    
  •  	Application.LoadLevel(1);*
    
  •  }*
    
  •  if(GUI.Button(new Rect(500, 210, 300, 100), "Quit Game")) {*
    
  •  	Application.Quit();*
    
  •  }*
    
  •  if(GUI.Button(new Rect(500, 320, 300, 100), "Options Menu")) {*
    
  •  	showOptions = true;*
    
  •  }*
    
  •  if(showOptions == true) {*
    
  •  	//INCREASE QUALITY PRESET*
    
  •  	if(GUI.Button(new Rect(810, 100, 300, 100), "Increase Quality")) {*
    
  •  		QualitySettings.IncreaseLevel();*
    
  •  		Debug.Log ("Increased quality");*
    
  •  	}*
    
  •  	//DECREASE QUALITY PRESET*
    
  •  	if(GUI.Button(new Rect(810, 210, 300, 100), "Decrease Quality")) {*
    
  •  		QualitySettings.DecreaseLevel();*
    
  •  		Debug.Log ("Decreased quality");*
    
  •  	}*
    
  •  	//0 X AA SETTINGS*
    
  •  	if(GUI.Button(new Rect(810, 320, 65, 100), "No AA")) {*
    
  •  		QualitySettings.antiAliasing = 0;*
    
  •  		Debug.Log ("0 AA");*
    
  •  	}*
    
  •  	//2 X AA SETTINGS*
    
  •  	if(GUI.Button(new Rect(879, 320, 65, 100), "2x AA")) {*
    
  •  		QualitySettings.antiAliasing = 2;*
    
  •  		Debug.Log ("2 x AA");*
    
  •  	}*
    
  •  	//4 X AA SETTINGS*
    
  •  	if(GUI.Button(new Rect(954, 320, 65, 100), "4x AA")) {*
    
  •  		QualitySettings.antiAliasing = 4;*
    
  •  		Debug.Log ("4 x AA");*
    
  •  	}*
    
  •  	//8 x AA SETTINGS*
    
  •  	if(GUI.Button(new Rect(1028, 320, 65, 100), "8x AA")) {*
    
  •  		QualitySettings.antiAliasing = 8;*
    
  •  		Debug.Log ("8 x AA");*
    
  •  	}*
    
  •  	//TRIPLE BUFFERING SETTINGS*
    
  •  	if(GUI.Button(new Rect(810, 430, 140, 100), "Triple Buffering On")) {*
    
  •  		QualitySettings.maxQueuedFrames = 3;*
    
  •  		Debug.Log ("Triple buffering on");*
    
  •  	}*
    
  •  	if(GUI.Button(new Rect(955, 430, 140, 100), "Triple Buffering Off")) {*
    
  •  		QualitySettings.maxQueuedFrames = 0;*
    
  •  		Debug.Log ("Triple buffering off");*
    
  •  	}*
    
  •  	//ANISOTROPIC FILTERING SETTINGS*
    
  •  	if(GUI.Button(new Rect(190, 100, 300, 100), "Anisotropic Filtering On")) {*
    
  •  		QualitySettings.anisotropicFiltering = AnisotropicFiltering.ForceEnable;*
    
  •  		Debug.Log ("Force enable anisotropic filtering!");*
    
  •  	}*
    
  •  	if(GUI.Button(new Rect(190, 210, 300, 100), "Anisotropic Filtering Off")) {*
    
  •  		QualitySettings.anisotropicFiltering = AnisotropicFiltering.Disable;*
    
  •  		Debug.Log ("Disable anisotropic filtering!");*
    
  •  	}*
    
  •  	//RESOLUTION SETTINGS*
    
  •  	//60Hz*
    
  •  	if(GUI.Button(new Rect(190, 320, 300, 100), "60Hz")) {*
    
  •  		Screen.SetResolution(ResX, ResY, Fullscreen, 60);*
    
  •  		Debug.Log ("60Hz");*
    
  •  	}*
    
  •  	//120Hz*
    
  •  	if(GUI.Button(new Rect(190, 430, 300, 100), "120Hz")) {*
    
  •  		Screen.SetResolution(ResX, ResY, Fullscreen, 120);*
    
  •  		Debug.Log ("120Hz");*
    
  •  	}*
    
  •  	//1080p*
    
  •  	if(GUI.Button(new Rect(500, 430, 93, 100), "1080p")) {*
    
  •  		Screen.SetResolution(1920, 1080, Fullscreen);*
    
  •  		ResX = 1920;*
    
  •  		ResY = 1080;*
    
  •  		Debug.Log ("1080p");*
    
  •  	}*
    
  •  	//720p*
    
  •  	if(GUI.Button(new Rect(596, 430, 93, 100), "720p")) {*
    
  •  		Screen.SetResolution(1280, 720, Fullscreen);*
    
  •  		ResX = 1280;*
    
  •  		ResY = 720;*
    
  •  		Debug.Log ("720p");*
    
  •  	}*
    
  •  	//480p*
    
  •  	if(GUI.Button(new Rect(692, 430, 93, 100), "480p")) {*
    
  •  		Screen.SetResolution(640, 480, Fullscreen);*
    
  •  		ResX = 640;*
    
  •  		ResY = 480;*
    
  •  		Debug.Log ("480p");*
    
  •  	}*
    
  •  	if(GUI.Button(new Rect(500, 0, 140, 100), "Vsync On")) {*
    
  •  		QualitySettings.vSyncCount = 1;*
    
  •  	}*
    
  •  	if(GUI.Button(new Rect(645, 0, 140, 100), "Vsync Off")) {*
    
  •  		QualitySettings.vSyncCount = 0;*
    
  •  	}*
    
  •  }*
    
  • }*
    }
    Could I get some help with this? I would do the C# one but it doesn’t look too nice.

@hellopeople0004
Have you considered using a dropdown instead of a series of IF statements so that it will be easier to narrow down the problem. Also, I’ve tested around with this and it seems that there will be no noticeable change in the editor. Yet when you build the project the resolution will change.

Please tell me if this helps

Sincerely
-The Guy that wrote this messages.