Переглянути джерело

增加切换exe窗口大小的功能

大爷 1 рік тому
батько
коміт
2ae16a7ad8

+ 1 - 1
FGUIProject/assets/Login/ComboBox1_popup.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <component size="460,400">
   <displayList>
-    <graph id="n0_px1c" name="n0" xy="0,0" size="460,400" touchable="false" type="rect" lineColor="#ffa0a0a0" fillColor="#ffccffff">
+    <graph id="n0_px1c" name="n0" xy="0,0" size="460,400" touchable="false" type="rect" lineColor="#ffa0a0a0">
       <relation target="" sidePair="width-width,height-height"/>
     </graph>
     <list id="n1_px1c" name="list" xy="0,0" size="460,200" overflow="scroll" defaultItem="ui://2jxt4hn8px1csr">

BIN
Unity/Assets/Res/FGUI/Login_fui.bytes


+ 34 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/UI/UILogin/AppStartInitFinish_CreateLoginUI.cs

@@ -2,7 +2,6 @@
 using FairyGUI;
 using Sirenix.Utilities;
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
 using UnityEngine;
@@ -86,7 +85,41 @@ namespace ET.Client
 
         private void InitResolutionList(GComboBox list)
         {
+#if UNITY_EDITOR             
+            list.visible = false;
+#elif UNITY_STANDALONE
+            list.visible = true;
+            int val = GameSetting.Instance.GetInt(GameSetting.Sets.Resolution_int, 0);
+            int select = -1;
+            List<string> showlist = new();
+            foreach (var info in ResolutionInfo.ResolutionList)
+            {
+                showlist.Add(info.ShowName);
+
+                if (select < 0 && val == info.Y)
+                {
+                    select = showlist.Count - 1;
+                }
+            }
+            if (select < 0)
+            {
+                select = 0;
+            }
+            var cur = ResolutionInfo.ResolutionList[select];
+            Screen.SetResolution(cur.X, cur.Y, false);
+            Log.Debug($"Default resolution x:{cur.X}, y:{cur.Y}");
 
+            list.items = showlist.ToArray();
+            list.selectedIndex = select;
+            list.onChanged.Set(() =>
+            {
+                var info = ResolutionInfo.ResolutionList[list.selectedIndex];
+                GameSetting.Instance.SetInt(GameSetting.Sets.Resolution_int, info.Y);
+
+                Screen.SetResolution(info.X, info.Y, false);
+                Log.Debug($"SetResolution x:{info.X}, y:{info.Y}");
+            });
+#endif
         }
 
         private void InitLogin(Scene scene, GComponent view)

+ 15 - 0
Unity/Assets/Scripts/Codes/Model/Client/GameSetting.cs

@@ -8,6 +8,8 @@ namespace ET
         {
             Mute_int,
             Server_str,
+            Resolution_int,
+
         }
 
         public bool GetBool(Sets sets)
@@ -32,5 +34,18 @@ namespace ET
             var keys = sets.ToString();
             PlayerPrefs.SetString(keys, value);
         }
+
+        public int GetInt(Sets sets, int defaultVal = 0)
+        {
+            var key = sets.ToString();
+
+            return PlayerPrefs.GetInt(key, defaultVal);
+        }
+
+        public void SetInt(Sets sets, int value)
+        {
+            var key = sets.ToString();
+            PlayerPrefs.SetInt(key, value);
+        }
     }
 }

+ 0 - 3
Unity/Assets/Scripts/Loader/MonoBehaviour/Init.cs

@@ -8,9 +8,6 @@ namespace ET
 	{
 		private void Awake()
 		{
-#if UNITY_STANDALONE_WIN
-			Screen.SetResolution(608, 1080, false);
-#endif
 #if UNITY_EDITOR
 			//Editor模式下去掉debug浮窗插件
 			var debugObj = GameObject.Find("IngameDebugConsole");

+ 1 - 1
Unity/ProjectSettings/ProjectSettings.asset

@@ -48,7 +48,7 @@ PlayerSettings:
   m_SloganImage: {fileID: 0}
   m_SloganHeight: 150
   m_HolographicTrackingLossScreen: {fileID: 0}
-  defaultScreenWidth: 640
+  defaultScreenWidth: 540
   defaultScreenHeight: 960
   defaultScreenWidthWeb: 960
   defaultScreenHeightWeb: 600