diff --git a/Assets/Src/Core/Network/SocketConn.cs b/Assets/Src/Core/Network/SocketConn.cs index f1983223c..6e3a86b50 100644 --- a/Assets/Src/Core/Network/SocketConn.cs +++ b/Assets/Src/Core/Network/SocketConn.cs @@ -125,6 +125,15 @@ public class SocketConn #endif } + /* + 连接服务器gate端口规则: + 1. Editor模式使用ip和固定端口:6411 + 2. WebGL包使用http和ws协议的,使用ip和端口:6412 + 3. WebGL包使用https和wss协议的,使用域名和固定端口:4430 + 连接服务器serverlist端口规则: + 1. ip+端口模式:使用端口 6410 + 2. 域名模式:使用https默认端口443 + */ public bool Connect(string host, int port, float timeout = 1f) { if (mSocketState != enSocketState.Disconnected) @@ -152,7 +161,7 @@ public class SocketConn string address = ""; if (CommonUtil.IsValidIPv4(host)) { - address = string.Format("ws://{0}:{1}", host, port); + address = string.Format("ws://{0}:{1}", host, 6412); } else { @@ -170,6 +179,8 @@ public class SocketConn mLastPort = port; m_fBeginConnectTime = Time.realtimeSinceStartup; #else + // Editor 模式固定端口 6411 + port = 6411; mSocket = new Socket(newAddressFamily, SocketType.Stream, ProtocolType.Tcp); IPAddress addr = IPAddress.Parse(newServerIp); IPEndPoint endpoint = new IPEndPoint(addr, port); diff --git a/Assets/Src/Core/Resource/AssetsMgr.cs b/Assets/Src/Core/Resource/AssetsMgr.cs index 407ce00c8..f9918b211 100644 --- a/Assets/Src/Core/Resource/AssetsMgr.cs +++ b/Assets/Src/Core/Resource/AssetsMgr.cs @@ -1454,7 +1454,9 @@ public class AssetsMgr : SingletonMono yield break; } + int loadCount = 0; List racs = new List(); + Dictionary assetDict = new Dictionary(); string path = ""; for (int i = 0; i < assetName.Length; ++i) { @@ -1470,11 +1472,20 @@ public class AssetsMgr : SingletonMono } //RuntimeAnimatorController rac = UnityEditor.AssetDatabase.LoadAssetAtPath(path); - var handle = Addressables.LoadAssetAsync(path); - yield return handle; - racs.Add(handle.Result); + var currAssetName = assetName[i]; + Addressables.LoadAssetAsync(path).Completed += handle => + { + assetDict[currAssetName] = handle.Result; + loadCount++; + }; } } + while (loadCount < assetName.Length) { yield return null; } + + for (int i = 0; i < assetName.Length; ++i) + { + racs.Add(assetDict[assetName[i]]); + } if (Application.isPlaying) yield return new WaitForEndOfFrame(); callback.DynamicInvoke(racs, seqId, pathName, assetName); @@ -1482,6 +1493,8 @@ public class AssetsMgr : SingletonMono else if (typeof(T).Equals(typeof(List))) { List gos = new List(); + int loadCount = 0; + Dictionary dict = new Dictionary(); for (int i = 0; i < assetName.Length; ++i) { if (!string.IsNullOrEmpty(assetName[i])) @@ -1496,11 +1509,19 @@ public class AssetsMgr : SingletonMono } //AudioClip ac = UnityEditor.AssetDatabase.LoadAssetAtPath(path); - var handle = Addressables.LoadAssetAsync(path); - yield return handle; - gos.Add(handle.Result); + var currAssetName = assetName[i]; + Addressables.LoadAssetAsync(path).Completed += handle => + { + dict[currAssetName] = handle.Result; + loadCount++; + }; } } + while (loadCount < assetName.Length) { yield return null; } + for (int i = 0; i < assetName.Length; ++i) + { + gos.Add(dict[assetName[i]]); + } if (Application.isPlaying) yield return new WaitForEndOfFrame(); diff --git a/Assets/Src/GameLogic/LuaMgr.cs b/Assets/Src/GameLogic/LuaMgr.cs index f3d533be1..1ac50854c 100644 --- a/Assets/Src/GameLogic/LuaMgr.cs +++ b/Assets/Src/GameLogic/LuaMgr.cs @@ -54,9 +54,14 @@ public class LuaMgr : SingletonMono { var tolua_zip_data = await AssetsMgr.Instance.LoadLocalFileData(Application.streamingAssetsPath + "/" + Constants.LuaDirMergeFile); UnzipLuaFiles(tolua_zip_data); + GC.Collect(); + long before = GC.GetTotalMemory(true); var lua_zip_data = await AssetsMgr.Instance.LoadLocalFileData(Application.streamingAssetsPath + "/" + Constants.LuaLogicDirMergeFile); //UnzipLuaFiles(lua_zip_data); + _luaLogicZip = CommonUtil.GetZipFile(lua_zip_data); + long after = GC.GetTotalMemory(true); + Debug.Log($"_luaLogicZip size: {before} : {after}"); var pb_zip_data = await AssetsMgr.Instance.LoadLocalFileData(Application.streamingAssetsPath + "/" + Constants.LuaPbDirMergeFile); UnzipPbFiles(pb_zip_data); }