Exemplo n.º 1
0
 protected virtual void DoBegin()
 {
     m_ExportHandler           = new ExporterHandle();
     m_ExportHandler.IsDone    = false;
     EditorApplication.update += OnUpdate;
     m_ExportEnumerator        = DoExport();
 }
Exemplo n.º 2
0
        protected override IEnumerator DoExport()
        {
            if (m_IsCleanAll)
            {
                //TODO:导出前先清除所有的unit
                MapEditorSetting mapEditorSetting = MapEditorUtility.GetMapEditorSetting();
                string           exportAssetPath  = string.Format("{0}/{1}"
                                                                  , mapEditorSetting.AssetExportDirectory
                                                                  , Constants.UNIT_PREFAB_EXPORT_DIRECTORY);
                exportAssetPath = MapEditorUtility.GetFullPath(exportAssetPath);

                string[] unitFiles = Directory.GetFiles(exportAssetPath, "*.prefab", SearchOption.AllDirectories);

                if (unitFiles != null && unitFiles.Length > 0)
                {
                    UTF8Encoding utf8 = new UTF8Encoding(false);
                    for (int iFile = 0; iFile < unitFiles.Length; iFile++)
                    {
                        EditorUtility.DisplayProgressBar("删除所有unit", unitFiles[iFile], iFile * 1.0f / unitFiles.Length);
                        File.Delete(unitFiles[iFile]);
                        yield return(null);
                    }
                }
                EditorUtility.ClearProgressBar();
                AssetDatabase.Refresh();
            }
            yield return(null);

            if (m_MapPaths != null && m_MapPaths.Count > 0)
            {
                for (int iMap = 0; iMap < m_MapPaths.Count; iMap++)
                {
                    string       mapPath         = m_MapPaths[iMap];
                    Scene        iterScene       = EditorSceneManager.OpenScene(mapPath, OpenSceneMode.Single);
                    GameObject[] rootGameObjects = iterScene.GetRootGameObjects();
                    for (int iRootGameObject = 0; iRootGameObject < rootGameObjects.Length; iRootGameObject++)
                    {
                        GameObject iterGameObject = rootGameObjects[iRootGameObject];
                        Map        iterMap        = iterGameObject.GetComponent <Map>();
                        if (iterMap)
                        {
                            ExporterHandle handle = iterMap.ExportMap();
                            while (!handle.IsDone)
                            {
                                yield return(null);
                            }
                        }
                    }
                }
            }
            yield return(null);

            ///导出所有结束后 把公用unit放到单独目录下
            IEnumerator findCommonUnitsEnumerator = new Exporter().FindCommonUnits();

            while (findCommonUnitsEnumerator.MoveNext())
            {
                yield return(null);
            }
        }