- Home /
Question by
CristiBala24 · Aug 12, 2018 at 04:04 PM ·
ui3dunity5resolution settingsoptions
Resolution settings not working in build mode, but working perfectly in editor
So I made a script for resolutions settings and it works perfectly in editor, but when i build it i have to press multiple times on the buttons to get to the next resolution.
Here is the code:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class Resolutions : MonoBehaviour {
public Text resText;
private int resIndex = 0;
private Resolution[] resolutions;
// Use this for initialization
void Start () {
resolutions = Screen.resolutions;
Screen.SetResolution(resolutions[resIndex].width, resolutions[resIndex].width, true);
}
// Update is called once per frame
void Update () {
resText.text = resolutions[resIndex].width + "x" + resolutions[resIndex].height;
}
public void PreviousResolution()
{
resIndex--;
if(resIndex < 0)
{
resIndex = Screen.resolutions.Length - 1;
}
}
public void NextResolution()
{
resIndex++;
if(resIndex > Screen.resolutions.Length - 1)
{
resIndex = 0;
}
}
public void OnMouseUp()
{
Screen.SetResolution(resolutions[resIndex].width, resolutions[resIndex].height, true);
}
}
And here is how my options panel looks like:
capture.jpg
(56.6 kB)
Comment
Your answer
Follow this Question
Related Questions
Menu Options 1 Answer
Having a bit of trouble with Unity5's canvas 1 Answer
Forcing a program to initialize inside Unity game. 1 Answer
How to connect a variable to a UI text object 0 Answers
Tech tree element positioning 0 Answers