From a233b17574daeffe08ada844ab81e32d96c1a904 Mon Sep 17 00:00:00 2001 From: qiangye2 <90683784+qiangye2@users.noreply.github.com> Date: Wed, 23 Feb 2022 13:45:28 +0800 Subject: [PATCH] =?UTF-8?q?web=20GL=20=E8=BF=90=E8=A1=8C=E6=8A=A5=E9=94=99?= =?UTF-8?q?=20=20=E4=BF=AE=E6=94=B9=E7=BA=BF=E7=A8=8B=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=92=8Cshader=E5=8F=98=E4=BD=93=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Src/Core/Config/ConfigMgr.cs | 37 +++++++++++++++++++ Assets/Src/Core/Resource/AssetsMgr.cs | 7 +++- Assets/Src/ToLuaExtend/LuaLauncher.cs | 10 ++++- .../Plugins/WebGl.meta | 8 ++++ .../Plugins/WebGl/common/31.txt | 0 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 Build/BuildDependenceResource/Plugins/WebGl.meta create mode 100644 Build/BuildDependenceResource/Plugins/WebGl/common/31.txt diff --git a/Assets/Src/Core/Config/ConfigMgr.cs b/Assets/Src/Core/Config/ConfigMgr.cs index df04a843c..6015a58d1 100644 --- a/Assets/Src/Core/Config/ConfigMgr.cs +++ b/Assets/Src/Core/Config/ConfigMgr.cs @@ -81,12 +81,46 @@ public class ConfigMgr : Singleton void OnCallBack(List objs, string path_, string[] assetNames_) { + if (objs == null || objs.Count <= 0) { EventMgr.DispatchEvent(new CoreEvent(ECoreEventType.EID_ConfigMgrInit, 0)); return; } +#if UNITY_WEBGL && !UNITY_EDITOR ///WebGL不支持线程 + { + string keyword = "LanguagePackage"; + string keywordname = string.Format("{0}{1}", keyword, CurLangKey); + string curname = string.Empty; + TextAsset tx; + for (int i = 0; i < objs.Count; ++i) + { + tx = objs[i]; + curname = tx.name; + + if (curname.Contains(keyword) && !curname.Equals(keywordname) || tx.text.Length <= 0) + continue; + + Dictionary> ts = getData(curname, tx.text); + if (ConfigDictionary.ContainsKey(curname)) + { + ConfigDictionary[curname] = ts; + } + else + { + ConfigDictionary.Add(curname, ts); + } + } + m_bInitCSVFinished = true; + keyword = string.Empty; + keywordname = string.Empty; + curname = string.Empty; + tx = null; + CheckCfgOk(); + + } +#else if (LaunchThread.HasInstance()) { string keyword = "LanguagePackage"; @@ -129,6 +163,7 @@ public class ConfigMgr : Singleton } else { + string keyword = "LanguagePackage"; string keywordname = string.Format("{0}{1}", keyword, CurLangKey); string curname = string.Empty; @@ -157,7 +192,9 @@ public class ConfigMgr : Singleton curname = string.Empty; tx = null; CheckCfgOk(); + } +#endif } void OnLoadXmlCallback(List objs, string path_, string[] assetNames_) diff --git a/Assets/Src/Core/Resource/AssetsMgr.cs b/Assets/Src/Core/Resource/AssetsMgr.cs index 1bb1c0f50..384a91973 100644 --- a/Assets/Src/Core/Resource/AssetsMgr.cs +++ b/Assets/Src/Core/Resource/AssetsMgr.cs @@ -424,6 +424,7 @@ public class AssetsMgr : SingletonMono IEnumerator DownLoadFromRemoteAsync(string assetName, string localPath) { string url = string.Format("{0}{1}", FileSystem.RemotePackagePaht, assetName); + using (UnityWebRequest igRequest = UnityWebRequest.Get(url)) { igRequest.downloadHandler = new DownloadHandlerFile(localPath); @@ -447,6 +448,7 @@ public class AssetsMgr : SingletonMono // } Debug.Log(assetName + " has been download Aync to location : " + localPath); } + } IEnumerator DownLoadFromRemoteAsync_callback(string assetName, string localPath, System.Delegate callback) @@ -580,7 +582,7 @@ public class AssetsMgr : SingletonMono path = "file://" + path; } #else - path = string.Format("{0}assetsmapping.bytes", FileSystem.LocalPackagePath); + path = string.Format("{0}assetsmapping.bytes", FileSystem.RemotePackagePaht); #endif WWW www = new WWW(path); yield return www; @@ -667,6 +669,7 @@ public class AssetsMgr : SingletonMono path = string.Format("{0}{1}", FileSystem.LocalPackagePath, shaderName); #endif } + AssetBundleCreateRequest shaderABCreateRequest = AssetBundle.LoadFromFileAsync(path, 0, offset); yield return shaderABCreateRequest; AssetBundle shaderAB = shaderABCreateRequest.assetBundle; @@ -675,7 +678,9 @@ public class AssetsMgr : SingletonMono Bundle bundle = new Bundle(shaderAB, shaderName); mBundlesLoaded.Add(shaderName, bundle); } +#if UNITY_WEBGL && UNITY_EDITOR Shader.WarmupAllShaders(); +#endif if (completeCB != null) completeCB(true); } diff --git a/Assets/Src/ToLuaExtend/LuaLauncher.cs b/Assets/Src/ToLuaExtend/LuaLauncher.cs index 8dab5ba5b..4edbb52d0 100644 --- a/Assets/Src/ToLuaExtend/LuaLauncher.cs +++ b/Assets/Src/ToLuaExtend/LuaLauncher.cs @@ -1,4 +1,4 @@ -using UnityEngine; +using UnityEngine; using System; using System.Threading; using LuaInterface; @@ -31,16 +31,24 @@ public class LuaLauncher : LuaClient protected override void CallMain() { + DebugHelper.LogError("开始拉起lua manager文件!!!"); StartLooper(); LuaMgr.Instance.CallMain(); } protected override void StartMain() { +#if UNITY_WEBGL && !UNITY_EDITOR + DebugHelper.LogError("开始加载lua文件!!!"); + LuaMgr.Instance.StartMain(); + CallMain(); + UpdateTimer(); +#else if (LaunchThread.HasInstance()) { LaunchThread.Instance.Start(LaunchThread.AsyncLaunchState.LuaInit, LuaMgr.Instance.StartMain, CallMain, UpdateTimer); } +#endif } private void UpdateTimer() diff --git a/Build/BuildDependenceResource/Plugins/WebGl.meta b/Build/BuildDependenceResource/Plugins/WebGl.meta new file mode 100644 index 000000000..7497b3199 --- /dev/null +++ b/Build/BuildDependenceResource/Plugins/WebGl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 88007533a25f4f348913f7bea89a69ba +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Build/BuildDependenceResource/Plugins/WebGl/common/31.txt b/Build/BuildDependenceResource/Plugins/WebGl/common/31.txt new file mode 100644 index 000000000..e69de29bb