Exemplo n.º 1
0
        /// <summary>
        ///   生成场景默认数据
        /// </summary>
        static AssetBundleBuildData.SceneBuild GenerateSceneRuleData()
        {
            try
            {
                AssetBundleBuildData.SceneBuild scenes = new AssetBundleBuildData.SceneBuild();
                DirectoryInfo assets = new DirectoryInfo(EditorCommon.SCENE_START_PATH);
                if (assets.Exists)
                {
                    foreach (var f in assets.GetFiles("*.unity", SearchOption.AllDirectories))
                    {
                        scenes.Scenes.Add(new AssetBundleBuildData.SceneBuild.Element()
                        {
                            ScenePath = f.FullName, IsBuild = false
                        });
                    }
                }
                return(scenes);
            }
            catch (System.Exception ex)
            {
                Debug.LogWarning(ex.Message);
            }

            return(new AssetBundleBuildData.SceneBuild());
        }
Exemplo n.º 2
0
        /// <summary>
        ///   恢复所有场景
        /// </summary>
        public static void RestoreAllScene(AssetBundleBuildData.SceneBuild scene_rules)
        {
            for (int i = 0; i < scene_rules.Scenes.Count; ++i)
            {
                if (scene_rules.Scenes[i].IsBuild)
                {
                    RestoreSceneFromBackup(scene_rules.Scenes[i].ScenePath);
                }
            }

            ReturnDefaultOpenScene();
        }
Exemplo n.º 3
0
        /// <summary>
        ///   生成所有场景配置文件
        /// </summary>
        public static bool GenerateAllSceneConfig(AssetBundleBuildData.SceneBuild scene_rules)
        {
            RecordDefaultOpenScene();

            bool  cancel  = false;
            float total   = (float)scene_rules.Scenes.Count;
            float current = 0;

            for (int i = 0; i < scene_rules.Scenes.Count; ++i)
            {
                var scene = scene_rules.Scenes[i].ScenePath;
                if (scene_rules.Scenes[i].IsBuild)
                {
                    CopySceneToBackup(scene);
                    GenerateSceneConfig(scene);
                    AssetBundleNameTool.SetAssetBundleName(SceneConfig.GetSceneConfigPath(scene));
                    AssetBundleNameTool.SetAssetBundleName(scene);
                }
                else
                {
                    DeleteSceneConfig(scene);
                    AssetBundleNameTool.ClearAssetBundleName(scene);
                }


                current += 1.0f;
                float progress = current / total;
                if (EditorUtility.DisplayCancelableProgressBar("正在生成场景配置数据", "Change " + scene, progress))
                {
                    cancel = true;
                    break;
                }
            }

            EditorUtility.ClearProgressBar();

            return(!cancel);
        }
Exemplo n.º 4
0
        /// <summary>
        ///   调整场景数据(匹配最新的场景目录,删除无用数据)
        /// </summary>
        static void MatchSceneRuleData(ref AssetBundleBuildData.SceneBuild old)
        {
            AssetBundleBuildData.SceneBuild rules = new AssetBundleBuildData.SceneBuild();
            DirectoryInfo assets = new DirectoryInfo(EditorCommon.SCENE_START_PATH);

            if (assets.Exists)
            {
                foreach (var f in assets.GetFiles("*.unity", SearchOption.AllDirectories))
                {
                    var scene = old.Scenes.Find((elem) =>
                    {
                        return(elem.ScenePath == f.FullName);
                    });

                    bool is_build = scene != null && scene.IsBuild;
                    rules.Scenes.Add(new AssetBundleBuildData.SceneBuild.Element()
                    {
                        ScenePath = f.FullName, IsBuild = is_build
                    });
                }

                old = rules;
            }
        }