示例#1
0
        public static ExportParameter CreateExportParameter()
        {
            ExportParameter exportParameter = new ExportParameter();

            exportParameter.ExportedUnitAddressableKeys = new HashSet <string>();
            MapEditorSetting mapEditorSetting = MapEditorUtility.GetOrCreateMapEditorSetting();

            string exportAssetPath = string.Format("{0}/Units"
                                                   , mapEditorSetting.AssetExportDirectory);

            string[] resAssets = AssetDatabase.FindAssets("t:Prefab", new string[] { exportAssetPath });
            if (resAssets != null && resAssets.Length > 0)
            {
                for (int iRes = 0; iRes < resAssets.Length; iRes++)
                {
                    string   resPath  = AssetDatabase.GUIDToAssetPath(resAssets[iRes]);
                    string[] resSplit = resPath.Split('/');
                    if (resSplit != null && resSplit.Length > 0)
                    {
                        string   lastName      = resSplit[resSplit.Length - 1];
                        string[] lastNameSplit = lastName.Split('_');
                        if (lastNameSplit != null && lastNameSplit.Length == 2)
                        {
                            lastName = lastName.Replace(".prefab", "");
                            exportParameter.ExportedUnitAddressableKeys.Add(lastName);
                        }
                    }
                }
            }
            return(exportParameter);
        }
示例#2
0
        private IEnumerator Export_Co()
        {
            yield return(null);

            ExportParameter exportParameter = MapEditorUtility.CreateExportParameter();

            exportParameter.ThrowExceptionAtAbort       = true;
            exportParameter.ExportedUnitAddressableKeys = new HashSet <string>();

            string[] sceneGuids = AssetDatabase.FindAssets("t:Scene");
            for (int iScene = 0; iScene < sceneGuids.Length; iScene++)
            {
                Scene        iterScene       = EditorSceneManager.OpenScene(AssetDatabase.GUIDToAssetPath(sceneGuids[iScene]), 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 = new Exporter().BeginExport(iterMap, MapEditorUtility.GetOrCreateMapEditorSetting().ExportAllMapSetting, exportParameter);

                        ExporterHandle handle = new Exporter().BeginExport(iterMap, MapEditorUtility.GetOrCreateMapEditorSetting().ExportAllMapSetting, exportParameter, iterMap.GetAreaSpawnerList(), true);
                        while (!handle.IsDone)
                        {
                            yield return(null);
                        }
                    }
                }
            }
        }