//private YuU3dAppSetting locU3DApp; //public YuU3dAppSetting LocU3DApp //{ // get // { // if (locU3DApp != null && !string.IsNullOrEmpty(locU3DApp.LocAppId)) // { // return locU3DApp; // } // locU3DApp = YuEditorUtility.TryGetLocAppAtDir(Dir); // return locU3DApp; // } //} /// <summary> /// 获得自身目录下所有符合过滤配置的文件路径列表。 /// </summary> /// <returns></returns> public List <string> SelfDirPaths() { var paths = IOUtility.GetPaths(Dir); paths = paths.Where(p => AssetBundleBuilder.EndCheck(IgnoreRule, p)) .Where(p => AssetBundleBuilder.ContainCheck(IgnoreRule, p)).ToList(); return(paths); }
public AssetBundleBuildSizeInfo GetSizeInfo() { if (BuildType != AssetBundleBuildType.BuildAtSize) { throw new Exception($"目录{Dir}的打包方式不是尺寸打包!"); } var dirId = IOUtility.GetSomeDirPath(Dir, 3); AtSizeSetting.SizeInfo = new AssetBundleBuildSizeInfo(); var fileInfos = IOUtility.GetFileInfosAtDir(Dir, true) .Where(d => AssetBundleBuilder.EndCheck(IgnoreRule, d.FullName)) .Where(d => AssetBundleBuilder.ContainCheck(IgnoreRule, d.FullName)).ToList(); long maxSize = AtSizeSetting.PackageSize * 1024; long currentSize = 0; var bundleIndex = 0; var paths = new List <string>(); foreach (var fileInfo in fileInfos) { var path = fileInfo.FullName; path = path.ReplaceDoubleBackslash(); currentSize += fileInfo.Length; if (fileInfo.Length >= maxSize) { var assetId = Path.GetFileNameWithoutExtension(fileInfo.Name); AtSizeSetting.SizeInfo.AppOutFile(path, assetId); Debug.Log($"{fileInfo.Name} 文件大小大于尺寸分包的最大尺寸"); continue; } if (currentSize <= maxSize) { paths.Add(path); } else { AddSubPackage(); paths.Add(path); } } AddSubPackage(); // 添加最后一个子包尺寸小于分包限制的剩余资源 AtSizeSetting.SetSizeTotal(AtSizeSetting.SizeInfo.GetAssetTotal()); AssetBundleEditorDati.GetSingleDati().Save(); return(AtSizeSetting.SizeInfo); void AddSubPackage() { var subBundleId = $"{dirId}_{bundleIndex}".ToLower(); AtSizeSetting.SizeInfo.AddSubPacakage(subBundleId, paths); bundleIndex++; currentSize = 0; paths.Clear(); } }
public List <string> GetFileIds() { var paths = IOUtility.GetPaths(Dir); var ignoreRule = IgnoreRule; paths = paths.Where(p => AssetBundleBuilder.EndCheck(IgnoreRule, p)) .Where(p => AssetBundleBuilder.ContainCheck(IgnoreRule, p)).ToList(); var fileIds = paths.Select(Path.GetFileNameWithoutExtension).ToList(); return(fileIds); }
private static void SetTargetDirsBundleIdAndSelectBuild(bool isBuild, bool isSaveSetting) { var selectDir = UnityEditorUtility.GetSelectDir(); var targetApp = UnityEditorUtility.TryGetLocProjectInfoAtDir(selectDir); if (targetApp == null) { UnityEditorUtility.DisplayError("所选择的目录是一个无效目录,必须是一个应用允许打包的目录!"); return; } var dirs = IOUtility.GetAllDir(selectDir); var appAssetBundleSetting = AssetBundleEditorDati.GetActualInstance(); var dirSettings = new List <AssetBundleBuildSetting>(); foreach (var dir in dirs) { var setting = appAssetBundleSetting.GetSetting(dir); if (setting == null) { continue; } dirSettings.Add(setting); } AssetBundleBuilder.currentAssetBundleInfo = AssetBundleBuilder.GetAppAssetBundleInfo(targetApp.DevelopProjectName); for (int i = 0; i < dirSettings.Count; i++) { EditorUtility.DisplayProgressBar("设置 AB 包名", $"正在设置 {dirSettings[i].Dir} 文件夹的 AB 包名", i * 1.0f / dirSettings.Count); AssetBundleBuilder.SetBundleIdAndSelectIsBuild(dirSettings[i], isBuild, true, isSaveSetting); } EditorUtility.ClearProgressBar(); AssetBundleBuilder.SaveCurrentAppAssetBundleInfo(); AssetBundleEditorDati.GetSingleDati().Save(); }
public void SetBuildAtTargetBuildType(string dir, AssetBundleBuildType buildType) { var locAppId = UnityEditorUtility.GetLocAppIdAtSelectDir(); var appSetting = ProjectInfoDati.GetActualInstance(); if (locAppId == null) { Debug.LogError($"目标目录{dir}不是一个应用下的目录!"); return; } if (!AssetBundleBuilder.IsLegalAssetBundleDir(dir)) { Debug.LogError($"目标目录{dir}不是一个有效的AssetBundle目录!"); return; } var existSetting = BundleDirSettings.Find(s => s.Dir == dir); if (existSetting == null) { existSetting = new AssetBundleBuildSetting { BuildType = buildType, Dir = dir, //LocAppId = Unity3DEditorUtility.GetLocAppIdAtSelectDir() }; BundleDirSettings.Add(existSetting); BundleDirSettings = BundleDirSettings.OrderBy(s => s.Dir).ToList(); Debug.Log($"目录{dir}当前不存在配置数据,已新建配置!"); } else { existSetting.BuildType = buildType; Debug.Log($"目录{dir}已设置为基于{buildType}打包方式!"); } }
private void BuildThisDirAndNotClean() { AssetBundleBuilder.SetBundleIdAndSelectIsBuild(this); }
private void CleanAllBundleIdAndBuildThisDir() { AssetBundleBuilder.CleanAllAssetBundleId(); BuildThisDirAndNotClean(); }