|
@@ -9,7 +9,9 @@ namespace KairoEngine.Core.ConfigOptions
|
|
[CreateAssetMenu(fileName = "ScreenResolutionConfigOption", menuName = "KairoEngine/ConfigOptions/Screen Resolution", order = 1), HideMonoScript]
|
|
[CreateAssetMenu(fileName = "ScreenResolutionConfigOption", menuName = "KairoEngine/ConfigOptions/Screen Resolution", order = 1), HideMonoScript]
|
|
public class ScreenResolutionConfigOption : ConfigOptionBase
|
|
public class ScreenResolutionConfigOption : ConfigOptionBase
|
|
{
|
|
{
|
|
- [PropertyOrder(10)] public int defaultResolutionIndex;
|
|
|
|
|
|
+ public int minWidth = 720;
|
|
|
|
+ public int minHeigth = 480;
|
|
|
|
+ //[PropertyOrder(10)] public int defaultResolutionIndex;
|
|
|
|
|
|
[PropertyOrder(11), ListDrawerSettings(ShowPaging = false), PropertySpace(4,4)]
|
|
[PropertyOrder(11), ListDrawerSettings(ShowPaging = false), PropertySpace(4,4)]
|
|
public List<ResolutionData> resolutionList;
|
|
public List<ResolutionData> resolutionList;
|
|
@@ -30,15 +32,19 @@ namespace KairoEngine.Core.ConfigOptions
|
|
|
|
|
|
public override void LoadValue(bool debug)
|
|
public override void LoadValue(bool debug)
|
|
{
|
|
{
|
|
- currentResolutionIndex = PlayerPrefs.GetInt(id, defaultResolutionIndex);
|
|
|
|
showDebug = debug;
|
|
showDebug = debug;
|
|
|
|
+ SetResolutions();
|
|
|
|
+ if(resolutionList.Count == 0) return;
|
|
|
|
+ currentResolutionIndex = PlayerPrefs.GetInt(id, resolutionList.Count - 1);
|
|
ApplyConfig();
|
|
ApplyConfig();
|
|
//if(debug) Debug.Log($"{title} changed to {resolutionList[currentResolutionIndex].title}.");
|
|
//if(debug) Debug.Log($"{title} changed to {resolutionList[currentResolutionIndex].title}.");
|
|
}
|
|
}
|
|
|
|
|
|
public override void SetDefaultValue()
|
|
public override void SetDefaultValue()
|
|
{
|
|
{
|
|
- currentResolutionIndex = defaultResolutionIndex;
|
|
|
|
|
|
+ SetResolutions();
|
|
|
|
+ if(resolutionList.Count == 0) return;
|
|
|
|
+ currentResolutionIndex = PlayerPrefs.GetInt(id, resolutionList.Count - 1);
|
|
PlayerPrefs.SetInt(id, currentResolutionIndex);
|
|
PlayerPrefs.SetInt(id, currentResolutionIndex);
|
|
ApplyConfig();
|
|
ApplyConfig();
|
|
}
|
|
}
|
|
@@ -62,14 +68,7 @@ namespace KairoEngine.Core.ConfigOptions
|
|
else if(showDebug) Debug.Log($"Current resolution is already set to {res.ToString()}");
|
|
else if(showDebug) Debug.Log($"Current resolution is already set to {res.ToString()}");
|
|
}
|
|
}
|
|
|
|
|
|
- [Button("Apply Default"), PropertyOrder(13), ButtonGroup("Actions")]
|
|
|
|
- private void ApplyDefaultConfig()
|
|
|
|
- {
|
|
|
|
- currentResolutionIndex = defaultResolutionIndex;
|
|
|
|
- ApplyConfig();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- [Button("Reset Resolution List"), PropertyOrder(14), ButtonGroup("Actions")]
|
|
|
|
|
|
+ [Button("Load Resolution List"), PropertyOrder(14), ButtonGroup("Actions")]
|
|
private void SetResolutions()
|
|
private void SetResolutions()
|
|
{
|
|
{
|
|
resolutionList.Clear();
|
|
resolutionList.Clear();
|
|
@@ -79,6 +78,10 @@ namespace KairoEngine.Core.ConfigOptions
|
|
var res = resolutions[i];
|
|
var res = resolutions[i];
|
|
resolutionList.Add(new ResolutionData(res.ToString(), res.width, res.height, res.refreshRate));
|
|
resolutionList.Add(new ResolutionData(res.ToString(), res.width, res.height, res.refreshRate));
|
|
}
|
|
}
|
|
|
|
+ if(resolutionList.Count == 0)
|
|
|
|
+ {
|
|
|
|
+ if(showDebug) Debug.LogError("No resolutions found for this screen.");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private Resolution[] FilteredResolutions()
|
|
private Resolution[] FilteredResolutions()
|
|
@@ -87,6 +90,8 @@ namespace KairoEngine.Core.ConfigOptions
|
|
List<Resolution> filtered = new List<Resolution>();
|
|
List<Resolution> filtered = new List<Resolution>();
|
|
for (int i = 0; i < resolutions.Length; i++)
|
|
for (int i = 0; i < resolutions.Length; i++)
|
|
{
|
|
{
|
|
|
|
+ if(resolutions[i].width < minWidth) continue;
|
|
|
|
+ if(resolutions[i].height < minHeigth) continue;
|
|
if(resolutions[i].refreshRate == 59) continue;
|
|
if(resolutions[i].refreshRate == 59) continue;
|
|
if(resolutions[i].refreshRate == 50) continue;
|
|
if(resolutions[i].refreshRate == 50) continue;
|
|
if(resolutions[i].refreshRate == 30) continue;
|
|
if(resolutions[i].refreshRate == 30) continue;
|