private void Start() { #if UNITY_ANDROID MonoInstancePool.getInstance <SDK_Orientation>(true).ShowBar(); #endif Screen.fullScreen = true; MonoInstancePool.getInstance <AntiScriptSplit>(true); MonoInstancePool.getInstance <SDK_WeChat>(true); trUIAlert = UStaticFuncs.FindChildComponent <Transform>(transform, "UIAlert"); fprocessing = 0.1f; #if UNITY_IOS MonoInstancePool.getInstance <SDK_AppleInApp>(true); #endif gameObject.AddComponent <UConsoleDebug>(); #if !UNITY_WEBGL var fa = "fa" + Utils_Plugins.Util_GetBundleVersion(); if (!PlayerPrefs.HasKey(fa)) { AOutput.Log($"start copy files {fa}"); MonoInstancePool.getInstance <UCopyFilesFromStreamingAssets>().OnCopy("versions.txt", UStaticFuncs.ConfigSaveDir, () => { InitRemoteConfig(); PlayerPrefs.SetInt("fa" + Utils_Plugins.Util_GetBundleVersion(), 1); }); } else { #endif InitRemoteConfig(); #if !UNITY_WEBGL } #endif }
IEnumerator DelayLoadDll(byte[] bytes, byte[] pdbBytes) { fprocessing = 0.5f; yield return(new WaitForEndOfFrame()); ILRuntimeHandler.Instance.DoLoadDll("AHotGames", bytes, pdbBytes); fprocessing = 0.7f; ILRuntimeHandler.Instance.SetUnityMessageReceiver(MonoInstancePool.getInstance <UEmitMessage>(true).gameObject); var platform = ""; #if UNITY_ANDROID platform = "Android"; #elif UNITY_IOS platform = "IOS"; #else platform = "Windows"; #endif ILRuntimeHandler.Instance.OnLoadClass("AEntrance", new GameObject("AEntrance"), false, platform); #if ILRUNTIME ILRuntimeHandler.Instance.EmitMessage(bIsLocal ? "local" : "remote"); ILRuntimeHandler.Instance.EmitMessage($"resPath:{ConfigDownloader.Instance.OnGetValue("resPath")}"); fprocessing = 0.8f; #endif fprocessing = 1f; }
private void LoadDll(byte[] bytes, byte[] pdbBytes) { ILRuntimeHandler.Instance.DoLoadDll("ahotmages", bytes, pdbBytes); ILRuntimeHandler.Instance.SetUnityMessageReceiver(MonoInstancePool.getInstance <UEmitMessage>(true).gameObject); ILRuntimeHandler.Instance.OnLoadClass("AEntrance", new GameObject("AEntrance"), false, UConfigManager.bUsingAb.ToString()); }
IEnumerator DelayLoadDll(byte[] bytes, byte[] pdbBytes) { yield return(new WaitForEndOfFrame()); ILRuntimeHandler.Instance.DoLoadDll("ahotgames", bytes, pdbBytes); ILRuntimeHandler.Instance.SetUnityMessageReceiver(MonoInstancePool.getInstance <UEmitMessage>(true).gameObject); ILRuntimeHandler.Instance.OnLoadClass("AEntrance", new GameObject("AEntrance"), false, UConfigManager.bUsingAb.ToString()); }
IEnumerator DelayLoadDll(byte[] bytes, byte[] pdbBytes) { yield return(new WaitForEndOfFrame()); ILRuntimeHandler.Instance.DoLoadDll("AHotGames", bytes, pdbBytes); ILRuntimeHandler.Instance.SetUnityMessageReceiver(MonoInstancePool.getInstance <UEmitMessage>(true).gameObject); ILRuntimeHandler.Instance.OnLoadClass("AEntrance", new GameObject("AEntrance"), false, UConfigManager.bUsingAb.ToString()); ILRuntimeHandler.Instance.EmitMessage(bIsLocal ? "local" : "remote"); ILRuntimeHandler.Instance.EmitMessage($"resPath:{ConfigDownloader.Instance.OnGetValue("resPath")}"); }
private void Start() { ConfigDownloader.Instance.StartToDownload(ConfigURL, () => { ParseConfigs(); Debug.Log("UConfigManager.bUsingAb " + UConfigManager.bUsingAb); UAssetBundleDownloader.Instance.DownloadResources((l1) => { UAssetBundleDownloader.Instance.DownloadResources((l2) => { var dll = "Dll/AHotGames"; byte[] pdbBytes = null; #if UNITY_EDITOR if (!UConfigManager.bUsingAb) { dll += ".bytes"; } pdbBytes = System.IO.File.ReadAllBytes("Assets/RemoteResources/Dll/AHotGames.pdb"); #endif ILRuntimeHandler.Instance.DoLoadDll("ahotmages" , UAssetBundleDownloader.Instance.OnLoadAsset <TextAsset>(dll).bytes, pdbBytes); ILRuntimeHandler.Instance.SetUnityMessageReceiver(MonoInstancePool.getInstance <UEmitMessage>(true).gameObject); ILRuntimeHandler.Instance.OnLoadClass("AEntrance", new GameObject("AEntrance")); } , null, (arg) => { var preloads = ConfigDownloader.Instance.OnGetValue("preloads"); var lPreloads = preloads.Split(',').ToList(); foreach (var p in lPreloads) { if (arg.ToLower().StartsWith(p.ToLower())) { return(true); } } return(false); }); } , null, null, true, UStaticFuncs.GetPlatformFolder(Application.platform) , UStaticFuncs.GetPlatformFolder(Application.platform) + ".manifest"); }, () => { Debug.LogError("下载配置文件失败。"); }); }
private void Start() { gameObject.AddComponent <UConsoleDebug>(); var fa = "fa" + Utils_Plugins.Util_GetBundleVersion(); AOutput.Log($"local version {fa}"); if (!PlayerPrefs.HasKey(fa)) { AOutput.Log($"start copy files {fa}"); MonoInstancePool.getInstance <UCopyFilesFromStreamingAssets>().OnCopy("versions.txt", UStaticFuncs.ConfigSaveDir, () => { InitRemoteConfig(); PlayerPrefs.SetInt("fa" + Utils_Plugins.Util_GetBundleVersion(), 1); }); } else { InitRemoteConfig(); } }
IEnumerator DelayLoadDll(byte[] bytes, byte[] pdbBytes) { fprocessing = 0.5f; yield return(new WaitForEndOfFrame()); ILRuntimeHandler.Instance.DoLoadDll("AHotGames", bytes, pdbBytes); fprocessing = 0.7f; ILRuntimeHandler.Instance.SetUnityMessageReceiver(MonoInstancePool.getInstance <UEmitMessage>(true).gameObject); ILRuntimeHandler.Instance.OnLoadClass("AEntrance", new GameObject("AEntrance"), false, UConfigManager.bUsingAb.ToString()); ILRuntimeHandler.Instance.EmitMessage(bIsLocal ? "local" : "remote"); ILRuntimeHandler.Instance.EmitMessage($"resPath:{ConfigDownloader.Instance.OnGetValue("resPath")}"); fprocessing = 0.8f; #if UNITY_EDITOR #if UNITY_IOS ILRuntimeHandler.Instance.EmitMessage("targetRuntime:IOS", "AEntrance"); #elif UNITY_ANDROID ILRuntimeHandler.Instance.EmitMessage("targetRuntime:Android", "AEntrance"); #endif #endif fprocessing = 1f; }
private void Start() { ConfigDownloader.Instance.StartToDownload(ConfigURL, () => { UAssetBundleDownloader.Instance.DownloadResources((l1) => { UAssetBundleDownloader.Instance.DownloadResources((l2) => { var dll = "Dll/AHotGames"; #if UNITY_EDITOR dll += ".bytes"; #endif ILRuntimeHandler.Instance.DoLoadDll("ahotmages", UAssetBundleDownloader.Instance.OnLoadAsset <TextAsset>(dll).bytes); ILRuntimeHandler.Instance.SetUnityMessageReceiver(MonoInstancePool.getInstance <UEmitMessage>(true).gameObject); ILRuntimeHandler.Instance.OnLoadClass("AEntrance", new GameObject("AEntrance")); } , null, (arg) => { return(arg.Contains("dll/")); }, true); } , null, null, true, UStaticFuncs.GetPlatformFolder(Application.platform) , UStaticFuncs.GetPlatformFolder(Application.platform) + ".manifest"); }, () => { Debug.LogError("下载配置文件失败。"); }); }
public void EmitMessage(string msg) { Debug.Log("Receive message " + msg); var amsg = msg.Split(new char[] { '|' }); if (amsg[0] == "load") { var obj = UAssetBundleDownloader.Instance.OnLoadAsset <GameObject>(amsg[2]); if (!obj) { obj = new GameObject(amsg[1]); } else { obj = Instantiate(obj); } ILRuntimeHandler.Instance.OnLoadClass(amsg[1], obj); } else if (amsg[0] == "loadprefab") { var obj = UAssetBundleDownloader.Instance.OnLoadAsset <GameObject>(amsg[1]); if (obj == null) { obj = new GameObject(amsg[1]); } else { obj = Instantiate(obj); } #if ILRUNTIME ILRuntimeHandler.Instance.EmitGameObject(amsg[1], obj, amsg.Length > 2 ? amsg[2] : ""); #endif } else if (amsg[0] == "unloadall") { ILRuntimeHandler.Instance.OnUnloadAllClasses(); } else if (amsg[0] == "invoke") { var ainvoke = amsg[1].Split(new char[] { ':' }, 3); if (ainvoke.Length >= 2) { var objname = ainvoke[0]; var obj = MonoInstancePool.OnGetInstance(objname); if (obj == null) { var aobj = objname.Split('/'); if (aobj.Length == 2) { obj = GameObject.Find(aobj[0]); if (obj != null) { var tr = UStaticFuncs.FindChildComponent <Transform>(obj.transform, aobj[1]); if (tr != null) { obj = tr.gameObject; } else { Debug.Log($"cannot find {aobj[1]}"); } } else { Debug.Log($"cannot find {aobj[0]}"); } } else { obj = GameObject.Find(objname); } if (obj == null) { Debug.Log($"Cannot find obj {objname}"); return; } } if (ainvoke.Length == 2) { obj.SendMessage(ainvoke[1]); } else { obj.SendMessage(ainvoke[1], ainvoke[2]); } } else { Debug.Log($"Invoke 参数数量错误 {msg}"); } } }