private Coroutine OnAssetBundlesLoading(AbstractAssetBundleRef abf, string md5) { nAssetBundleLoaded += 1; assetsRate = (float)nAssetBundleLoaded / nAssetBundleToLoad; LogTime("ABF#" + abf); return(null); }
// streamingRootPath中的lua脚本加载完成 private Coroutine OnStreamingLuaLoaded(AbstractAssetBundleRef abf, string md5) { // 更新streamingRootPath中lua脚本的md5 string streamingMD5 = PlayerPrefs.GetString(KEY_MD5_STREAMING_LUA); string streamingDate = PlayerPrefs.GetString(KEY_DATE_STREAMING_LUA); if (md5 != streamingMD5) { streamingMD5 = md5; streamingDate = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); PlayerPrefs.SetString(KEY_MD5_STREAMING_LUA, streamingMD5); PlayerPrefs.SetString(KEY_DATE_STREAMING_LUA, streamingDate); LogMgr.I("Update streaming lua to {0} at {1}", streamingMD5, streamingDate); } string bundlePath = Path.Combine(AssetBundleLoader.bundleRootPath, LUA_SCRIPT); string bundleMD5 = PlayerPrefs.GetString(KEY_MD5_USING_LUA); string bundleDate = PlayerPrefs.GetString(KEY_DATE_USING_LUA); if (File.Exists(bundlePath) && !string.IsNullOrEmpty(bundleMD5)) { if (streamingMD5 != bundleMD5) { // 已存在lua脚本在bundleRootPath, 比较时间 var dtStreaming = System.DateTime.Parse(streamingDate); var dtUsing = System.DateTime.Parse(bundleDate); if (dtUsing < dtStreaming) { // Streaming 的Lua脚本比较新 File.Delete(bundlePath); // 所有资源需要更新 if (Directory.Exists(AssetBundleLoader.bundleRootPath)) { Directory.Delete(AssetBundleLoader.bundleRootPath, true); Directory.CreateDirectory(AssetBundleLoader.bundleRootPath); } PlayerPrefs.SetString(KEY_MD5_USING_LUA, streamingMD5); PlayerPrefs.SetString(KEY_DATE_USING_LUA, streamingDate); LogMgr.I("Update using lua to {0} at {1}", streamingMD5, streamingDate); } else { // 移除Streaming中的旧脚本,加载新脚本 abf.Unload(true); AssetBundleLoader.Instance.BundleTask(LUA_SCRIPT, false); } } } else { // 首次启动游戏 PlayerPrefs.SetString(KEY_MD5_USING_LUA, streamingMD5); PlayerPrefs.SetString(KEY_DATE_USING_LUA, streamingDate); LogMgr.I("First using lua to {0} at {1}", streamingMD5, streamingDate); } //加载UIRoot AssetBundleLoader.Instance.BundleTask(LUA_CONFIG, false, OnAssetsLaunched); return(null); }
private static Coroutine OnAssetBundleLoaded(AbstractAssetBundleRef abf, string md5) { Debug.Log("Starting Init Scence!"); // Scene Init var L = Instance.L; L.GetGlobal(F_ON_LEVEL_LOADED); L.DoCall(0, SceneManager.GetActiveScene().name, true); return(null); }
/// <summary> /// 在此函数中加载UIRoot /// </summary> /// <param name="abRef"></param> /// <param name="md5"></param> /// <returns></returns> private Coroutine OnAssetsLaunched(AbstractAssetBundleRef abRef, string md5) { if (UIManager.Instance == null) { LoadAsync(typeof(GameObject), "Launch/UIROOT", false, (o, p) => { GoTools.AddForever(o as GameObject); }); } return(null); }
private Coroutine OnAssetBundlesLoaded(AbstractAssetBundleRef abf, string md5) { assetsRate = 1; return(null); }