Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Why when changing resolution while game running using the exe built file everything is too blurry ?

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Chocolade, Dec 2, 2019 at 11:31 PM.

  1. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    611


    The default resolution is 1920x1080 and the ui elements are sharp and fine. Once I changed the resolution to 640x480 but it's the same on other resolutions either everything get blurry and the buttons are not responding all I can click on is the RESOLUTION dropdown and change the resolution and if I will change it back to the defalut 1920x1080 then everything will be looking sharp again and I will be able to click on the buttons and change all other ui's.

    How can I fix it so on any resolution it will looks sharp and also will respond ?

    This is how it looks like on the default 1920x1080 :



    This is my Main Menu hierarchy :




    And this is the script that attached to the Canvas :

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.Audio;
    6. using UnityEngine.UI;
    7.  
    8. public class SettingsMenu : MonoBehaviour
    9. {
    10.    public AudioMixer audioMixer;
    11.    public Text volumeInPercentages;
    12.    public Dropdown resolutionDropDown;
    13.  
    14.    [SerializeField]
    15.    private Slider _volumeSlider;
    16.    [SerializeField]
    17.    private Dropdown _dropDownQuality;
    18.  
    19.    private Resolution[] resolutions;
    20.  
    21.    private void Start()
    22.    {
    23.        resolutions = Screen.resolutions;
    24.        resolutionDropDown.ClearOptions();
    25.  
    26.        List<string> options = new List<string>();
    27.  
    28.        int currentResolutionIndex = 0;
    29.        for (int i = 0; i < resolutions.Length; i++)
    30.        {
    31.            string option = resolutions[i].width + " x " + resolutions[i].height
    32.                 + " " + resolutions[i].refreshRate.ToString() + " Hz";
    33.            options.Add(option);
    34.  
    35.            if (resolutions[i].width == Screen.currentResolution.width &&
    36.                resolutions[i].height == Screen.currentResolution.height)
    37.            {
    38.                currentResolutionIndex = i;
    39.            }
    40.        }
    41.  
    42.        resolutionDropDown.AddOptions(options);
    43.        resolutionDropDown.value = currentResolutionIndex;
    44.        resolutionDropDown.RefreshShownValue();
    45.    }
    46.  
    47.    public void SetVolume()
    48.    {
    49.        float volume = _volumeSlider.value;
    50.        Debug.Log("Volume " + volume);
    51.        audioMixer.SetFloat("MusicVol", Mathf.Log10(volume) * 20);
    52.        volumeInPercentages.text = Mathf.Round(volume * 100).ToString() + " %";
    53.    }
    54.  
    55.    public void SetQuality()
    56.    {
    57.        int qualityIndex = _dropDownQuality.value;
    58.        QualitySettings.SetQualityLevel(qualityIndex);
    59.    }
    60.  
    61.    public void SetFullScreen()
    62.    {
    63.        Screen.fullScreen = !Screen.fullScreen;
    64.    }
    65.  
    66.    public void SetResolution()
    67.    {
    68.        Resolution resolution = resolutions[resolutionDropDown.value];
    69.        Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
    70.    }
    71. }
    72.