//获取公共资源列表 public static List <Download_Vesal_info> GetStructInfo(asset_platform platform) { print("当前平台:" + Enum.GetName(typeof(asset_platform), platform)); List <Download_Vesal_info> list = new List <Download_Vesal_info>(); var local_db = new DbRepository <CommonAssetLib>(); local_db.DataService("vesali.db"); var tmpIe = local_db.Select <CommonAssetLib>((tempNo) => { if (tempNo.url != null && tempNo.platform == Enum.GetName(typeof(asset_platform), platform)) { // DebugLog.DebugLogInfo("公共资源 名称:" + tempNo.ab_name + " " + tempNo.url + " version " + tempNo.version); return(true); } else { return(false); } }); foreach (var i in tmpIe) { Download_Vesal_info temp_info = new Download_Vesal_info(); if ((PublicClass.Quality == Run_Quality.POOL) && PublicTools.isTargetInSourceList(i.ab_name, PublicClass.low_res_ablist, ',') && (i.type == "AB")) { temp_info.url = i.url.Insert(i.url.LastIndexOf(i.ab_name), "s_"); temp_info.name = "s_" + i.ab_name; } else { temp_info.name = i.ab_name; temp_info.url = i.url; } temp_info.version = i.version; temp_info.isNeedDownload = false; temp_info.type = i.type; temp_info.instance = null; temp_info.source = null; // print(temp_info.name); list.Add(temp_info); } local_db.Close(); return(list); }
private List <Download_Vesal_info> load_download_list_from_file(string fname_path) { try { List <Download_info> temp; if (!File.Exists(fname_path)) { return(new List <Download_Vesal_info>()); } FileStream fs = new FileStream(fname_path, FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); temp = bf.Deserialize(fs) as List <Download_info>; fs.Close(); if (temp == null) { return(new List <Download_Vesal_info>()); } List <Download_Vesal_info> res = new List <Download_Vesal_info>(); //Debug.Log("temp count" + temp.Count); for (int i = 0; i < temp.Count; i++) { Download_Vesal_info item = new Download_Vesal_info(); //Debug.Log(temp[i].name + temp[i].version); item.name = temp[i].name; item.url = temp[i].url; item.version = temp[i].version; item.type = temp[i].type; item.isNeedDownload = temp[i].isNeedDownload; res.Add(item); } return(res); } catch { return(new List <Download_Vesal_info>()); } }
void cacaulte_load_list() { load_list = new List <Download_Vesal_info>(); string downloaded_str = ""; foreach (Download_Vesal_info download in PublicClass.Asset_loaded_list) { downloaded_str += download.name; } print("PublicClass.total_load_list :" + PublicClass.total_load_list.Count); if (this_app.ab_list == null || (this_app.ab_list.Trim() == "")) { foreach (Download_Vesal_info download in PublicClass.total_load_list) { if (!downloaded_str.Contains(Vesal_DirFiles.remove_name_suffix(download.name))) { download.type = "AB"; load_list.Add(download); } } } else { string[] ab_files = this_app.ab_list.Split(','); string ablist_str = ""; for (int k = 0; k < ab_files.Length; k++) { //if (PublicClass.low_res_ablist.Contains(ab_files[k])) // ab_files[k] = "s_"+ab_files[k]; ablist_str += ab_files[k]; if (!downloaded_str.Contains(ab_files[k])) { foreach (Download_Vesal_info download in PublicClass.total_load_list) { if (download.name.Contains(ab_files[k])) { download.type = "AB"; load_list.Add(download); break; } } } } // //对于性能差的机型,卸载掉不用的ab包模型数据 // if ((PublicClass.Quality == Run_Quality.POOL) && (load_list.Count + PublicClass.Asset_loaded_list.Count() >= PublicClass.MAX_Ab_num)) // { // bool unload = false; // for (int k = PublicClass.Asset_loaded_list.Count() - 1; k >= 0; k--) // { // Download_Vesal_info temp = PublicClass.Asset_loaded_list[k]; // if (!PublicTools.isTargetInSourceList(Vesal_DirFiles.remove_name_suffix(temp.name), PublicClass.app.ab_list)) // { // UnityEngine.Debug.Log("POOL Destroy::" + temp.name); // try // { // DestroyImmediate(temp.instance); // //Destroy(temp.source); // } // catch (Exception e) // { // UnityEngine.Debug.Log(e.Message); // } // Resources.UnloadUnusedAssets(); // PublicClass.Asset_loaded_list.RemoveAt(k); // unload = true; // } // } // if (unload) // ReadModelAgain(); // } } if (PublicClass.app.app_type == "sign_acu") { Download_Vesal_info download = new Download_Vesal_info(); download.name = "acu_path/" + Vesal_DirFiles.remove_name_suffix(PublicClass.app.ab_path) + "/acupoint.assetbundle"; download.type = "TEMP"; load_list.Add(download); } print("downloaded_strdownloaded_str :" + downloaded_str); UnityEngine.Debug.Log("加载ab 包 长度:" + load_list.Count); }
void cacaulte_load_list() { load_list = new List <Download_Vesal_info>(); if (PublicClass.app.app_type == "demo") { return; } string downloaded_str = ""; foreach (Download_Vesal_info download in PublicClass.Asset_loaded_list) { downloaded_str += download.name; } Debug.Log("loaded ablist---:" + downloaded_str); //if (PublicClass.app.ab_list == null || (PublicClass.app.ab_list.Trim() == "")) //{ string ab = ""; List <string> ablist = new List <string>(); foreach (string model in temp.scope_scene_model_name) { if (!PublicClass.Model_AB_dic.ContainsKey(model)) { Debug.Log("the model not founded in ab !!!!!!!!!!!!!!!" + model); continue; } string modelab = PublicClass.Model_AB_dic[model]; if (ab != modelab) { if (!ablist.Contains(modelab)) { ab = modelab; ablist.Add(modelab); Download_Vesal_info item = new Download_Vesal_info(); item.type = "AB"; item.name = ab + ".assetbundle"; if (!downloaded_str.Contains(item.name)) { load_list.Add(item); } } } } //foreach (Download_Vesal_info download in PublicClass.total_load_list) //{ // if (!downloaded_str.Contains(Vesal_DirFiles.remove_name_suffix(download.name))) // { // load_list.Add(download); // } //} //} //else //{ // Debug.Log("app ablist---:" + PublicClass.app.ab_list); // string[] ab_files = PublicClass.app.ab_list.Split(','); // string ablist_str = ""; // Debug.Log("app ablist---number:" + ab_files.Length); // for (int k = 0; k < ab_files.Length; k++) // { // //if (PublicClass.low_res_ablist.Contains(ab_files[k])) // // ab_files[k] = "s_"+ab_files[k]; // //ablist_str += ab_files[k]; // if (!downloaded_str.Contains(ab_files[k] + ".assetbundle")) // { // bool founded = false; // foreach (Download_Vesal_info download in PublicClass.total_load_list) // { // if (download.name.Contains(ab_files[k] + ".assetbundle")) // { // founded = true; // load_list.Add(download); // break; // } // } // if (!founded) // { // Debug.Log("ab list error:" + ab_files[k]); // } // } // } //} //卸载掉不用的ab包模型数据 string ab_list_string = ""; foreach (string str in ablist) { ab_list_string += (str + ","); } if ((PublicClass.Quality == Run_Quality.POOL) && (load_list.Count + PublicClass.Asset_loaded_list.Count() >= PublicClass.MAX_Ab_num)) { bool unload = false; for (int k = PublicClass.Asset_loaded_list.Count() - 1; k >= 0; k--) { Download_Vesal_info tmp = PublicClass.Asset_loaded_list[k]; if (!PublicTools.isTargetInSourceList(Vesal_DirFiles.remove_name_suffix(tmp.name), ab_list_string)) { Debug.Log("POOL Destroy::" + tmp.name); try { DestroyImmediate(tmp.instance); //Destroy(temp.source); } catch (Exception e) { Debug.Log(e.Message); } Resources.UnloadUnusedAssets(); PublicClass.Asset_loaded_list.RemoveAt(k); unload = true; } } if (unload) { ReadModelAgain(); } } }