/// <summary> /// 异步加载一个依赖包 /// </summary> /// <param name="relyBundleName"></param> /// <param name="callBack"></param> public static void LoadRelyBundleAsync(string relyBundleName, RelyBundleLoadCallBack callBack) { if (relyBundle.ContainsKey(relyBundleName)) { RelyBundle tmp = relyBundle[relyBundleName]; tmp.relyCount++; callBack(LoadState.CompleteState, tmp); } else { //先占位,避免重复加载 relyBundle.Add(relyBundleName, null); BundleConfig configTmp = BundleConfigManager.GetRelyBundleConfig(relyBundleName); string path = GetBundlePath(configTmp); ResourceIOTool.AssetsBundleLoadAsync(path, (LoadState state, AssetBundle bundle) => { if (!state.isDone) { callBack(state, null); } else { callBack(state, AddRelyBundle(relyBundleName, bundle)); } }); } }
public void Test_1() { BundleConfigManager.Initialize(); ResourceManager.gameLoadType = ResLoadType.Resource; DataTable data = DataManager.GetData("testData"); Assert.NotNull(data); }
public void LoadByResource() { BundleConfigManager.Initialize(); ResourceManager.gameLoadType = ResLoadType.Resource; GameObject testTmp = (GameObject)ResourceManager.Load("UItest 1"); Assert.NotNull(testTmp); }
public void Test_2() { BundleConfigManager.Initialize(); ResourceManager.gameLoadType = ResLoadType.Resource; DataTable data = DataManager.GetData("testData"); Assert.AreEqual(data.defaultValue["name"], "张三"); //Assert.AreEqual(data["1"].GetString("name"), "李四"); }
public void CheckConfig() { BundleConfigManager.Initialize(); ResourceManager.gameLoadType = ResLoadType.Streaming; BundleConfig packConfig = BundleConfigManager.GetBundleConfig("UItest 5"); Assert.NotNull(packConfig); }
public void Test_3() { BundleConfigManager.Initialize(); ResourceManager.gameLoadType = ResLoadType.Resource; DataTable data = DataManager.GetData("bugs"); Assert.AreEqual(data.defaultValue["bug编号"], "37"); Assert.AreEqual(data["1"].GetString("bug编号"), "1"); Assert.AreEqual(data["1"].GetInt("bug编号"), 1); }
public void LoadByBundle() { BundleConfigManager.Initialize(); ResourceManager.gameLoadType = ResLoadType.Streaming; GameObject testTmp = (GameObject)ResourceManager.Load("UItest 3"); //Instantiate(testTmp); Assert.NotNull(testTmp); }
public void LoadByBundleAsync() { BundleConfigManager.Initialize(); ResourceManager.gameLoadType = ResLoadType.Streaming; ResourceManager.LoadAsync("UItest 4", (LoadState state, object obj) => { GameObject go = (GameObject)obj; Assert.NotNull(go); }); }
/// <summary> /// 异步加载一个bundle /// </summary> /// <param name="bundleName">bundle名</param> public static void LoadBundleAsync(string bundleName, BundleLoadCallBack callBack) { BundleConfig configTmp = BundleConfigManager.GetBundleConfig(bundleName); if (configTmp == null) { Debug.LogError("LoadBundleAsync: " + bundleName + " dont exist!"); return; } string path = GetBundlePath(configTmp); LoadState state = new LoadState(); Dictionary <string, LoadState> loadStateDict = new Dictionary <string, LoadState>(); //先加载依赖包 for (int i = 0; i < configTmp.relyPackages.Length; i++) { LoadRelyBundleAsync(configTmp.relyPackages[i], (LoadState relyLoadState, RelyBundle RelyBundle) => { if (RelyBundle != null && relyLoadState.isDone) { Debug.Log(RelyBundle.bundle.name); loadStateDict.Add(RelyBundle.bundle.name, relyLoadState); state.progress += 1 / ((float)configTmp.relyPackages.Length + 1); } //所有依赖包加载完毕加载资源包 if (loadStateDict.Keys.Count == configTmp.relyPackages.Length) { ResourceIOTool.AssetsBundleLoadAsync(path, (LoadState bundleLoadState, AssetBundle bundle) => { if (bundleLoadState.isDone) { callBack(LoadState.CompleteState, AddBundle(bundleName, bundle)); } else { state.progress += bundleLoadState.progress / ((float)configTmp.relyPackages.Length + 1); callBack(state, null); } }); } else { callBack(state, null); } }); } }
static Dictionary <string, RelyBundle> relyBundle = new Dictionary <string, RelyBundle>(); //所有依赖包 /// <summary> /// 同步加载一个bundles /// </summary> /// <param name="name">bundle名</param> public static Bundle LoadBundle(string bundleName) { BundleConfig configTmp = BundleConfigManager.GetBundleConfig(bundleName); string path = GetBundlePath(configTmp); //加载依赖包 for (int i = 0; i < configTmp.relyPackages.Length; i++) { LoadRelyBundle(configTmp.relyPackages[i]); } return(AddBundle(bundleName, AssetBundle.LoadFromFile(path))); }
public void LoadByResourceAsync() { BundleConfigManager.Initialize(); ResourceManager.gameLoadType = ResLoadType.Resource; ResourceManager.LoadAsync("UItest 2", (LoadState state, object obj) => { if (state.isDone) { GameObject go = (GameObject)obj; Assert.NotNull(go); } else { Debug.Log(state.progress); } }); }
public static Bundle AddBundle(string bundleName, AssetBundle aess) { Bundle bundleTmp = new Bundle(); BundleConfig configTmp = BundleConfigManager.GetBundleConfig(bundleName); if (bundles.ContainsKey(bundleName)) { bundles[bundleName] = bundleTmp; } else { bundles.Add(bundleName, bundleTmp); } bundleTmp.bundleConfig = configTmp; if (aess != null) { bundleTmp.bundle = aess; bundleTmp.bundle.name = bundleName; bundleTmp.mainAsset = bundleTmp.bundle.mainAsset; bundleTmp.bundle.Unload(false); //如果有缓存起来的回调这里一起回调 if (LoadAsyncDict.ContainsKey(bundleName)) { try { LoadAsyncDict[bundleName](LoadState.CompleteState, bundleTmp.mainAsset); } catch (Exception e) { Debug.Log("LoadAsync AddBundle " + e.ToString()); } } } else { Debug.LogError("AddBundle: " + bundleName + " dont exist!"); } return(bundleTmp); }
//加载一个依赖包 public static RelyBundle LoadRelyBundle(string relyBundleName) { RelyBundle tmp = null; if (relyBundle.ContainsKey(relyBundleName)) { tmp = relyBundle[relyBundleName]; tmp.relyCount++; } else { BundleConfig configTmp = BundleConfigManager.GetRelyBundleConfig(relyBundleName); string path = GetBundlePath(configTmp); tmp = AddRelyBundle(relyBundleName, AssetBundle.LoadFromFile(path)); } return(tmp); }
public IEnumerator Initialize() { if (IsInited) { yield break; } //首先初始化ConfigManager,各种数据由configManager中得到 yield return(StartCoroutine(BundleConfigManager.Init())); BmConfiger = BundleConfigManager.BmConfiger; // Start download for requests before init foreach (BundleRequest request in _requestedBeforeInit) { download(request); } IsInited = true; }
public static object Load(string name) { BundleConfig packData = BundleConfigManager.GetBundleConfig(name); if (packData == null) { throw new Exception("Load Exception not find " + name); } ResLoadType loadTypeTmp = GetLoadType(packData.loadType); if (loadTypeTmp == ResLoadType.Resource) { return(Resources.Load(packData.path)); } else { return(AssetsBundleManager.Load(name)); } }
public static void LoadAsync(string name, LoadCallBack callBack) { BundleConfig packData = BundleConfigManager.GetBundleConfig(name); if (packData == null) { return; } ResLoadType loadTypeTmp = GetLoadType(packData.loadType); if (loadTypeTmp == ResLoadType.Resource) { ResourceIOTool.ResourceLoadAsync(packData.path, callBack); } else { AssetsBundleManager.LoadAsync(name, callBack); } }
/// <summary> /// assetbundle打包 /// </summary> /// <param name="target">目标平台</param> public static void Execute(UnityEditor.BuildTarget target) { BundleConfigManager.ReadConfig(); Dictionary <string, List <string> > bundles = BundleConfigManager.Bundles; string savePath = BundleConfigManager.SavePath + AssetBundleController.GetPlatformName(target) + '/'; if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } if (bundles.Count <= 0) { Debug.LogError(BundleConfigManager.ConfigFileName + " is empty."); return; } //打包 foreach (KeyValuePair <string, List <string> > bundle in bundles) { List <Object> objs = new List <Object>(); foreach (string path in bundle.Value) { FillObjToList(path, objs); } BuildPipeline.BuildAssetBundle(objs[0], objs.ToArray(), savePath + bundle.Key + ".assetbundle", _option, target); } //计算MD5 CreateMD5List.Execute(target); //比较MD5 CampareMD5ToGenerateVersionNum.Execute(target); //修改Version文件 CreateAssetBundleForXmlVersion.Execute(target); // scene目录下的资源 AssetDatabase.Refresh(); }
public ActionResult ReLoadConfig() { //重新加载各种配置 MongoDBConfig.LoadConfig(); ExcludeUrlConfiguration.LoadConfig(); UrlGenerateConfig.LoadConfig(); RedisConfig.LoadConfig(); SqlDispatcherConfig.LoadConfig(); //FastDFS.Configuration.FastDFSConfigHelper.LoadConfig(); BundleConfigManager.RegisterBundles(BundleTable.Bundles); string backUrl = Request.UrlReferrer == null?Url.RetechAction("Index") : Request.UrlReferrer.ToString(); return(Redirect(backUrl)); }
/// <summary> /// 程序启动 /// </summary> public void AppLaunch() { SetResourceLoadType(); //设置资源加载类型 BundleConfigManager.Initialize(); //资源路径管理器启动 Log.Init(); //日志系统启动 ApplicationStatusManager.Init(); //游戏流程状态机初始化 //初始化全局逻辑 InitGlobalLogic(); if (m_AppMode != AppMode.Release) { GUIConsole.Init(); //运行时Debug ApplicationStatusManager.EnterTestModel(m_Status); //可以从此处进入测试流程 } else { //游戏流程状态机,开始第一个状态 ApplicationStatusManager.EnterStatus(m_Status); } }
public override void OnEnterStatus() { BundleConfigManager.Initialize(); UIManager.Init(); }