Exemple #1
0
        private static void SetMeshImporterMat(Material mat)
        {
            var mainDir = UnityEditorUtility.GetSelectDir();
            var dirs    = IOUtility.GetAllDir(mainDir);

            if (dirs != null)
            {
                foreach (var dir in dirs)
                {
                    var fullDir = UnityIOUtility.GetFullPath(dir);
                    //Debug.LogError(dir);

                    var fullpaths = Directory.GetFiles(fullDir);
                    foreach (var item in fullpaths)
                    {
                        SetMeshImporterMat(item, mat);
                    }
                }
            }
            //var objs =  AssetDatabase.LoadAllAssetsAtPath(dir);
            //Debug.LogError(objs.Length);
            //foreach (var item in objs)
            //{
            //    Debug.LogError(item.name);
            //}
        }
        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();
        }