فهرست منبع

Updated the ResolutionOptions to include all types of displays

James Peret 2 سال پیش
والد
کامیت
e767181d60
1فایلهای تغییر یافته به همراه16 افزوده شده و 11 حذف شده
  1. 16 11
      Runtime/ConfigOptions/Templates/ScreenResolutionConfigOption.cs

+ 16 - 11
Runtime/ConfigOptions/Templates/ScreenResolutionConfigOption.cs

@@ -9,7 +9,9 @@ namespace KairoEngine.Core.ConfigOptions
     [CreateAssetMenu(fileName = "ScreenResolutionConfigOption", menuName = "KairoEngine/ConfigOptions/Screen Resolution", order = 1), HideMonoScript]
     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)]
         public List<ResolutionData> resolutionList;
@@ -30,15 +32,19 @@ namespace KairoEngine.Core.ConfigOptions
 
         public override void LoadValue(bool debug)
         {
-            currentResolutionIndex  = PlayerPrefs.GetInt(id, defaultResolutionIndex);
             showDebug = debug;
+            SetResolutions();
+            if(resolutionList.Count == 0) return;
+            currentResolutionIndex = PlayerPrefs.GetInt(id, resolutionList.Count - 1);
             ApplyConfig();
             //if(debug) Debug.Log($"{title} changed to {resolutionList[currentResolutionIndex].title}.");
         }
 
         public override void SetDefaultValue()
         {
-            currentResolutionIndex = defaultResolutionIndex;
+            SetResolutions();
+            if(resolutionList.Count == 0) return;
+            currentResolutionIndex = PlayerPrefs.GetInt(id, resolutionList.Count - 1);
             PlayerPrefs.SetInt(id, currentResolutionIndex);
             ApplyConfig();
         }
@@ -62,14 +68,7 @@ namespace KairoEngine.Core.ConfigOptions
             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() 
         {
             resolutionList.Clear();
@@ -79,6 +78,10 @@ namespace KairoEngine.Core.ConfigOptions
                 var res = resolutions[i];
                 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()
@@ -87,6 +90,8 @@ namespace KairoEngine.Core.ConfigOptions
             List<Resolution> filtered = new List<Resolution>();
             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 == 50) continue;
                 if(resolutions[i].refreshRate == 30) continue;