I am trying to change the resolution in my game.
I want may game to start on a given resolution defined in Script and after that as per user input,
But when i do that my screen just go black and nothing happen a prat from the size of my windowed game changes.
I have been searching for this but i am not been able to find a solution for what i am experiencing, everything just stuck and i dose not move at all
This is the code i am using
This is where my resolution is being set on play
void Awake()
{
resolutionPopup.value = "1024x768";
SetResolution("1024x768", false);
graphicsPopup.value = "Fantastic";
SetQuality(5);
}
this is where It gets the supported resolutions and add them to my popup window
void Start () {
GetRes();
GetQuality();
NumberOfMonitors();
Debug.Log("Start");
}
this is where i am getting all suported resolutions of monitor
void GetRes()
{
Resolution[] resolutions = Screen.resolutions;
foreach (Resolution res in resolutions)
{
string resolution = res.width.ToString() + "x" + res.height.ToString();
SetDropDowmResolution(resolution);
}
}
this is the method which sets the resolution in to popup
void SetDropDowmResolution(string res)
{
resolutionPopup.items.Add(res);
}
this is where my selected resolution is being set
void SetResolution(string res, bool fullscreen)
{
string[] resBreak = res.Split('x');
Vector2 resV2 = new Vector2(Int32.Parse(resBreak[0]), Int32.Parse(resBreak[1]));
Screen.SetResolution((int)resV2.x, (int)resV2.y, fullscreen);
}
i am using Set Resolution Method GUI button
Plz look into this matter as i am unable to solve it…
Thanks