/// <summary> /// 在 Addressables Groups 动态创建groups /// </summary> private static void addAddressablesGroups() { //先创建一个global AASUtility.CreateGroup("global", false); return; }
public static void RunCheckAssetBundle() { var initGroups = new string[] { "static_effect", "static_js", "static_models", "static_shaders", "static_fb", "static_fairygui" }; var start = DateTime.Now; //初始化Groups foreach (var g in initGroups) { AASUtility.CreateGroup(g); } Debug.Log("Finished Update Asset Path Map... " + (DateTime.Now - start).TotalSeconds + "s"); }
public static void RunCheckAssetBundle() { var initGroups = new string[] { "static_effect", "static_js", "static_models", "static_shaders", "static_ui", "static_fb", "static_jsmap", "static_fairygui" }; var start = DateTime.Now; //更新assetmap List <AddressableAssetEntry> assets = new List <AddressableAssetEntry>(); AASUtility.GetSettings().GetAllAssets(assets, false, (g) => { return(g.name.Equals("static_js")); }); string[] address = assets.Select(e => e.address).ToArray(); string assetFolder = Path.Combine(Application.dataPath, AddressableConfig.AssetsFolderName); var assetPathMap = Path.Combine(assetFolder, AddressableConfig.AssetsPathMapFileName); GameUtility.SafeWriteAllLines(assetPathMap, address); AssetDatabase.Refresh(); //初始化Groups foreach (var g in initGroups) { AASUtility.CreateGroup(g); } Debug.Log("Finished Update Asset Path Map... " + (DateTime.Now - start).TotalSeconds + "s"); }
private static void RunAllCheckersTask() { ThreadPars[] threadParses = new ThreadPars[ThreadCount]; for (int index = 0; index < ThreadCount; index++) { threadParses[index] = new ThreadPars(); } var guids = AssetDatabase.FindAssets("t:AddressableDispatcherConfig", new string[] { AddressableInspectorUtils.DatabaseRoot }); var length = guids.Length; var count = 0; foreach (var guid in guids) { count++; var assetPath = AssetDatabase.GUIDToAssetPath(guid); var config = AssetDatabase.LoadAssetAtPath <AddressableDispatcherConfig>(assetPath); config.Load(); int index = count % ThreadCount; threadParses[index].ChildDataList.Add(config); threadParses[index].is_atlas_model = EditorUserSettings.GetConfigValue(AddressableTools.is_atlas_model); } List <Task <Dictionary <string, List <string> > > > taskList = new List <Task <Dictionary <string, List <string> > > >(); taskList.Add(new Task <Dictionary <string, List <string> > >(() => { return(ThreadFind(threadParses[0])); })); taskList[0].Start(); taskList.Add(new Task <Dictionary <string, List <string> > >(() => { return(ThreadFind(threadParses[1])); })); taskList[1].Start(); taskList.Add(new Task <Dictionary <string, List <string> > >(() => { return(ThreadFind(threadParses[2])); })); taskList[2].Start(); taskList.Add(new Task <Dictionary <string, List <string> > >(() => { return(ThreadFind(threadParses[3])); })); taskList[3].Start(); for (int i = 0; i < ThreadCount; i++) { taskList[i].Wait(); } //Logger.LogError("=======over========="); Dictionary <string, UnityEditor.AddressableAssets.Settings.AddressableAssetGroup> groupsDic = new Dictionary <string, UnityEditor.AddressableAssets.Settings.AddressableAssetGroup>(); for (int i = 0; i < ThreadCount; i++) { foreach (var keyvalue in taskList[i].Result) { keyvalue.Value.Sort(); foreach (var pathStr in keyvalue.Value) { //Logger.LogError("path:" + pathStr + " groupName:" + keyvalue.Key); if (!groupsDic.ContainsKey(keyvalue.Key)) { groupsDic.Add(keyvalue.Key, AASUtility.CreateGroup(keyvalue.Key)); } UnityEditor.AddressableAssets.Settings.AddressableAssetEntry temp_entry = null; var s = AASUtility.GetSettings(); foreach (UnityEditor.AddressableAssets.Settings.AddressableAssetGroup group in s.groups) { if (group == null) { continue; } foreach (UnityEditor.AddressableAssets.Settings.AddressableAssetEntry entry in group.entries) { //Logger.LogError("entry.AssetPath:" + entry.AssetPath + " pathstr:" + pathStr + " group.name:" + group.name + " keyvalue.key:" + keyvalue.Key); if ((entry.AssetPath.Replace('\\', '/') == pathStr.Replace('\\', '/')) && (group.name == keyvalue.Key)) { //Logger.LogError("============temp_entry=====================" + pathStr); temp_entry = entry; } } } if (temp_entry == null) { //Logger.LogError("=================================" + pathStr); var guid = AssetDatabase.AssetPathToGUID(pathStr); AASUtility.AddAssetToGroup(guid, keyvalue.Key); } } } } AssetDatabase.Refresh(); }