private static void CleanAllSonDir()
        {
            locAppId  = UnityEditorUtility.GetLocAppIdAtSelectDir();
            locU3DApp = ProjectInfoDati.GetActualInstance();
            if (string.IsNullOrEmpty(locAppId))
            {
                UnityEditorUtility.DisplayError("所选择的目录不是一个应用下的有效目录!");
                return;
            }
            var assetbundleEditor = AssetBundleEditorDati.GetActualInstance();

            if (assetbundleEditor == null)
            {
                UnityEditorUtility.DisplayError($"应用{locAppId}没有AssetBundle打包配置!");
                throw new Exception($"应用{locAppId}没有AssetBundle打包配置!");
            }
            foreach (var dir in AllSonDirs)
            {
                if (!dir.StartsWith(locU3DApp.ProjectAssetDatabaseDir))
                // dir.StartsWith(appHelper.StreamingAssetsDir))
                {
                    Debug.LogError($"目标目录不是一个有效的AssetBundle打包目录!");
                    continue;
                }
                assetbundleEditor.CleanBuildSettingAtDir(dir);
            }
            AssetBundleEditorDati.GetSingleDati().Save();
        }
        /// <summary>
        /// 设置目标目录的打包类型
        /// </summary>
        /// <param name="buildType"></param>
        private static void SetTargetDirAtildType(AssetBundleBuildType buildType)
        {
            var projectInfo       = ProjectInfoDati.GetActualInstance();
            var assetbundleEditor = AssetBundleEditorDati.GetActualInstance();

            locAppId = projectInfo.DevelopProjectName;

            if (string.IsNullOrEmpty(locAppId))
            {
                UnityEditorUtility.DisplayError("未设置项目名称");
                return;
            }

            //appHelper = locU3DApp.Helper;

            if (assetbundleEditor == null)
            {
                Debug.LogError($"项目的 AssetBundleSetting 实例未创建 !");
                return;
            }

            var dirs = UnityEditorUtility.GetSelectDirs();

            foreach (var dir in dirs)
            {
                if (!dir.StartsWith(projectInfo.ProjectAssetDatabaseDir))
                {
                    Debug.LogError($"目标目录不是一个有效的AssetBundle打包目录!");
                    return;
                }
                assetbundleEditor.SetBuildAtTargetBuildType(dir, buildType);
                if (buildType == AssetBundleBuildType.BuildAtDirTree) // 清理所有子目录的打包配置
                {
                    var sonDirs = IOUtility.GetAllDir(dir, null, true, false);
                    foreach (var sonDir in sonDirs)
                    {
                        assetbundleEditor.CleanBuildSettingAtDir(sonDir);
                    }
                    Debug.Log($"目录{dir}已设置为目录树打包,其所有子目录的打包配置都已被清空!");
                }
            }
            AssetBundleEditorDati.GetSingleDati().Save();
        }
        private static void SetSonDirAtildType(AssetBundleBuildType buildType, List <string> dirs)
        {
            locAppId  = UnityEditorUtility.GetLocAppIdAtSelectDir();
            locU3DApp = ProjectInfoDati.GetActualInstance();
            if (string.IsNullOrEmpty(locAppId))
            {
                UnityEditorUtility.DisplayError("所选择的目录不是一个应用下的有效目录!");
                return;
            }

            foreach (var dir in dirs)
            {
                if (!dir.StartsWith(locU3DApp.ProjectAssetDatabaseDir))
                //&& dir.StartsWith(appHelper.StreamingAssetsDir))
                {
                    Debug.LogError($"目标目录不是一个有效的AssetBundle打包目录!");
                    continue;
                }

                var assetbundleEditor = AssetBundleEditorDati.GetActualInstance();
                if (assetbundleEditor == null)
                {
                    Debug.Log($"应用{locAppId}没有AssetBundle打包配置!");
                    return;
                }

                assetbundleEditor.SetBuildAtTargetBuildType(dir, buildType);
                if (buildType == AssetBundleBuildType.BuildAtDirTree) // 清理所有子目录的打包配置
                {
                    var sonDirs = IOUtility.GetAllDir(dir, null, true, false);
                    foreach (var sonDir in sonDirs)
                    {
                        assetbundleEditor.CleanBuildSettingAtDir(sonDir);
                    }
                    Debug.Log($"目录{dir}已设置为目录树打包,其所有子目录的打包配置都已被清空!");
                }
            }
            AssetBundleEditorDati.GetSingleDati().Save();
        }
        private static void CleanSelectDir()
        {
            var dirs      = UnityEditorUtility.GetSelectDirs();
            var targetApp = UnityEditorUtility.TryGetLocProjectInfoAtDir(dirs.First());

            if (targetApp == null)
            {
                UnityEditorUtility.DisplayError($"第一个目录必须是一个应用的允许打包目录!");
                return;
            }

            var assetbundleEditor = AssetBundleEditorDati.GetActualInstance();

            foreach (var dir in dirs)
            {
                //var dirSetting = appAssetBundleSetting.GetDirSetting(dir);
                //List<String> paths = null;
                //paths = dirSetting?.GetFullPathsAtDirTree();
                //assetbundleEditor.CleanBuildSettingAtDir(dir, paths);
            }
            AssetBundleEditorDati.GetSingleDati().Save();
        }
        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();
        }