/// <summary> /// 将所以的groups 设置成Remote_Static模式 /// </summary> public static void SetAllGroupsToRemoteStatic() { AddressableAssetSettings settings = AASUtility.GetSettings(); foreach (var group in settings.groups) { SetGroupsSetting(group, true, true, BundledAssetGroupSchema.BundleNamingStyle.AppendHash, AddressableAssetSettings.kRemoteBuildPath, AddressableAssetSettings.kRemoteLoadPath, true); } }
/// <summary> /// 将所以的groups 设置成Local_Static模式 /// </summary> public static void SetAllGroupsToLocalStatic() { AddressableAssetSettings settings = AASUtility.GetSettings(); foreach (var group in settings.groups) { SetGroupsSetting(group, false, false, BundledAssetGroupSchema.BundleNamingStyle.NoHash, AddressableAssetSettings.kLocalBuildPath, AddressableAssetSettings.kLocalLoadPath, true); } }
/// <summary> /// 将所以的groups 设置成Remote_NoStatic模式 /// </summary> public static void SetAllGroupsToRemoteNoStatic() { AddressableAssetSettings settings = AASUtility.GetSettings(); settings.OverridePlayerVersion = "1"; foreach (var group in settings.groups) { SetGroupsSetting(group, true, true, BundledAssetGroupSchema.BundleNamingStyle.NoHash, AddressableAssetSettings.kRemoteBuildPath, AddressableAssetSettings.kRemoteLoadPath, false); } }
public static string assetsPath = Path.Combine(Application.dataPath, Assets_Package); //资源目录 public static void RunCheckAssetBundle(bool _is_atlas_model = true) { EditorUserSettings.SetConfigValue(is_atlas_model, _is_atlas_model ? "1" : "0"); //先把之前的config删除 clear(assetspackageConfigPath); AddressableAssetSettings settings = AASUtility.GetSettings(); foreach (var group in settings.groups) { if (group == null) { Debug.LogError("addressable坏了"); } } //动态增加 addressables groups addAddressablesGroups(); //动态增加 config refreshConfig(); CheckAssetBundles.Run(); string assetFolder = Path.Combine(Application.dataPath, AssetBundleConfig.AssetsFolderName); //特殊文件 string app_version = Path.Combine(assetFolder, BuildUtils.AppVersionFileName); string assets_map = Path.Combine(assetFolder, AssetBundleConfig.AssetsPathMapFileName); string channel_name = Path.Combine(assetFolder, BuildUtils.ChannelNameFileName); string notice_version = Path.Combine(assetFolder, BuildUtils.NoticeVersionFileName); string res_version = Path.Combine(assetFolder, BuildUtils.ResVersionFileName); string ifix_map = Path.Combine(assetFolder, BuildUtils.IfixMapFileName); string config = Path.Combine(assetFolder, BuildUtils.ConfigFileName); SingleFileAddress("global", app_version); SingleFileAddress("global", assets_map); SingleFileAddress("global", channel_name); SingleFileAddress("global", notice_version); SingleFileAddress("global", res_version); SingleFileAddress("global", ifix_map); SingleFileAddress("global", config); //设置AssetBundle Provider SetAllGroupsToAssetBundleEncryptProvider(); //设置Asset Address SetAssetAddressAndLabel(); //将资源全部打成远程模式 SetAllGroupsToRemoteNoStatic(); }
private static void SetAllGroupsToAssetBundleEncryptProvider() { AddressableAssetSettings settings = AASUtility.GetSettings(); foreach (var group in settings.groups) { BundledAssetGroupSchema bundledAssetGroupSchema = group.GetSchema <BundledAssetGroupSchema>(); if (bundledAssetGroupSchema == null) { bundledAssetGroupSchema = group.AddSchema <BundledAssetGroupSchema>(); } bundledAssetGroupSchema.SetAssetBundleProviderType(typeof(AssetBundleEncryptProvider)); EditorUtility.SetDirty(bundledAssetGroupSchema); } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
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"); }
/// <summary> /// 自动设置asset的label,如果是皮肤下面的asset则会同时修改其address, 同时会将带皮肤的asset写入到文件中 /// /// </summary> public static void SetAssetAddressAndLabel() { Debug.Log("SetAllGroupsLabel Begin"); var setting = AASUtility.GetSettings(); foreach (var group in setting.groups) { string label = "default"; List <AddressableAssetEntry> assetEntry = new List <AddressableAssetEntry>(); group.GatherAllAssets(assetEntry, true, true, false); for (var i = 0; i < assetEntry.Count; i++) { //先清除掉asset身上的labels var labels = assetEntry[i].labels.ToArray <string>(); if (labels.Length == 1) { if (labels[0] != label) { for (var j = 0; j < labels.Length; j++) { assetEntry[i].SetLabel(labels[j], false); } assetEntry[i].SetLabel(label, true, true); } } else { for (var j = 0; j < labels.Length; j++) { assetEntry[i].SetLabel(labels[j], false); } assetEntry[i].SetLabel(label, true, true); } } } AssetDatabase.Refresh(); Debug.Log("SetAllGroupsLabel Finished"); }
public static void RunCheckAssetBundle() { var start = DateTime.Now; CheckAssetBundles.Run(); //更新assetmap List <AddressableAssetEntry> assets = new List <AddressableAssetEntry>(); AASUtility.GetSettings().GetAllAssets(assets, false, (g) => { return(g.name.Equals("lua")); }); string[] address = assets.Select(e => e.address).ToArray(); string assetPathMap = Path.Combine(Application.dataPath, AssetBundleConfig.AssetsFolderName); assetPathMap = Path.Combine(assetPathMap, AssetBundleConfig.AssetsPathMapFileName); GameUtility.SafeWriteAllLines(assetPathMap, address); AssetDatabase.Refresh(); //特殊文件 string app_version = Path.Combine(assetPathMap, "app_version.bytes"); string assets_map = Path.Combine(assetPathMap, "AssetsMap.bytes"); string channel_name = Path.Combine(assetPathMap, "channel_name.bytes"); string notice_version = Path.Combine(assetPathMap, "notice_version.bytes"); string res_version = Path.Combine(assetPathMap, "res_version.bytes"); SingleFileAddress("global", app_version); SingleFileAddress("global", assets_map); SingleFileAddress("global", channel_name); SingleFileAddress("global", notice_version); SingleFileAddress("global", res_version); Debug.Log("Finished CheckAssetBundles.Run! use " + (DateTime.Now - start).TotalSeconds + "s"); }
static void BuildHandle(PlatformType type, BuildOptions buildOptions, bool isBuildExe, bool clearFolder, bool isInject) { BuildTarget buildTarget = BuildTarget.StandaloneWindows; string programName = "ET"; string exeName = programName; string platform = ""; switch (type) { case PlatformType.PC: buildTarget = BuildTarget.StandaloneWindows64; exeName += ".exe"; IFixEditor.Patch(); platform = "pc"; break; case PlatformType.Android: KeystoreSetting(); buildTarget = BuildTarget.Android; exeName += ".apk"; IFixEditor.CompileToAndroid(); platform = "android"; break; case PlatformType.IOS: buildTarget = BuildTarget.iOS; IFixEditor.CompileToIOS(); platform = "ios"; break; case PlatformType.MacOS: buildTarget = BuildTarget.StandaloneOSX; IFixEditor.Patch(); platform = "pc"; break; } //打程序集 BuildAssemblieEditor.BuildCodeRelease(); if (isInject) { //Inject IFixEditor.InjectAssemblys(); } HandleProject(); //string fold = string.Format(BuildFolder, type); if (clearFolder && Directory.Exists(relativeDirPrefix)) { Directory.Delete(relativeDirPrefix, true); Directory.CreateDirectory(relativeDirPrefix); } else { Directory.CreateDirectory(relativeDirPrefix); } if (isBuildExe) { AssetDatabase.Refresh(); string[] levels = { "Assets/AssetsPackage/Scenes/InitScene/Init.unity", }; UnityEngine.Debug.Log("开始EXE打包"); BuildPipeline.BuildPlayer(levels, $"{relativeDirPrefix}/{exeName}", buildTarget, buildOptions); UnityEngine.Debug.Log("完成exe打包"); } string jstr = File.ReadAllText("Assets/AssetsPackage/config.bytes"); var obj = LitJson.JsonMapper.ToObject <Dictionary <string, string> >(jstr); string version = obj["ResVer"]; var settings = AASUtility.GetSettings(); string fold = Directory.GetParent(settings.RemoteCatalogBuildPath.GetValue(settings)).FullName; string targetPath = Path.Combine(relativeDirPrefix, $"{version}_{platform}"); if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } FileHelper.CleanDirectory(targetPath); FileHelper.CopyFiles(fold, targetPath); UnityEngine.Debug.Log("完成cdn资源打包"); }
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(); }