web GL 运行报错 修改线程代码,和shader变体代码

This commit is contained in:
qiangye2 2022-02-23 13:45:28 +08:00
parent dadf78abd3
commit a233b17574
5 changed files with 60 additions and 2 deletions

View File

@ -81,12 +81,46 @@ public class ConfigMgr : Singleton<ConfigMgr>
void OnCallBack(List<TextAsset> objs, string path_, string[] assetNames_)
{
if (objs == null || objs.Count <= 0)
{
EventMgr.DispatchEvent(new CoreEvent<int>(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<string, Dictionary<string, string>> 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<ConfigMgr>
}
else
{
string keyword = "LanguagePackage";
string keywordname = string.Format("{0}{1}", keyword, CurLangKey);
string curname = string.Empty;
@ -157,7 +192,9 @@ public class ConfigMgr : Singleton<ConfigMgr>
curname = string.Empty;
tx = null;
CheckCfgOk();
}
#endif
}
void OnLoadXmlCallback(List<TextAsset> objs, string path_, string[] assetNames_)

View File

@ -424,6 +424,7 @@ public class AssetsMgr : SingletonMono<AssetsMgr>
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<AssetsMgr>
// }
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<AssetsMgr>
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<AssetsMgr>
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<AssetsMgr>
Bundle bundle = new Bundle(shaderAB, shaderName);
mBundlesLoaded.Add(shaderName, bundle);
}
#if UNITY_WEBGL && UNITY_EDITOR
Shader.WarmupAllShaders();
#endif
if (completeCB != null) completeCB(true);
}

View File

@ -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()

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 88007533a25f4f348913f7bea89a69ba
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: