默认分辨率为1920x1080,并且ui元素清晰且精细。一旦我将分辨率更改为640x480,但在其他分辨率上相同,则所有内容都变得模糊并且按钮没有响应,我只能单击“分辨率”下拉列表并更改分辨率,如果我将其更改为默认1920x1080,则一切将会再次变得清晰,我将能够单击按钮并更改所有其他ui。
我该如何解决它,使它在任何分辨率下看起来都清晰并能响应?
这是默认的1920x1080上的样子:
这是我的主菜单层次结构:
以及附加到画布上的脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
public class SettingsMenu : MonoBehaviour
{
public AudioMixer audioMixer;
public Text volumeInPercentages;
public Dropdown resolutionDropDown;
[SerializeField]
private Slider _volumeSlider;
[SerializeField]
private Dropdown _dropDownQuality;
private Resolution[] resolutions;
private void Start()
{
resolutions = Screen.resolutions;
resolutionDropDown.ClearOptions();
List<string> options = new List<string>();
int currentResolutionIndex = 0;
for (int i = 0; i < resolutions.Length; i++)
{
string option = resolutions[i].width + " x " + resolutions[i].height
+ " " + resolutions[i].refreshRate.ToString() + " Hz";
options.Add(option);
if (resolutions[i].width == Screen.currentResolution.width &&
resolutions[i].height == Screen.currentResolution.height)
{
currentResolutionIndex = i;
}
}
resolutionDropDown.AddOptions(options);
resolutionDropDown.value = currentResolutionIndex;
resolutionDropDown.RefreshShownValue();
}
public void SetVolume()
{
float volume = _volumeSlider.value;
Debug.Log("Volume " + volume);
audioMixer.SetFloat("MusicVol", Mathf.Log10(volume) * 20);
volumeInPercentages.text = Mathf.Round(volume * 100).ToString() + " %";
}
public void SetQuality()
{
int qualityIndex = _dropDownQuality.value;
QualitySettings.SetQualityLevel(qualityIndex);
}
public void SetFullScreen()
{
Screen.fullScreen = !Screen.fullScreen;
}
public void SetResolution()
{
Resolution resolution = resolutions[resolutionDropDown.value];
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
}
}
这可能是您的.exe文件有问题。
选择“覆盖高dpi缩放行为并选择由应用程序执行的缩放。”>
希望对您有用。