private IEnumerator DoAnalyzeArea(Map map, AreaSpawner areaSpawner, bool showDialog = true) { string areaName = areaSpawner.GetAreaScenePath(); Area exportArea = null; Scene areaScene = EditorSceneManager.OpenScene(areaName, OpenSceneMode.Additive); if (areaScene != null) { SceneManager.SetActiveScene(areaScene); GameObject[] rootObjArray = areaScene.GetRootGameObjects(); if (rootObjArray != null && rootObjArray.Length > 0) { for (int index = 0; index < rootObjArray.Length; index++) { SceneManager.MoveGameObjectToScene(rootObjArray[index], map.GetOwnerScene()); Area area = rootObjArray[index].GetComponent <Area>(); if (area != null) { exportArea = area; } } } EditorSceneManager.CloseScene(areaScene, true); } yield return(null); if (exportArea != null) { areaSpawner.SetArea(exportArea); IEnumerator areaSpawnerEnumerator = areaSpawner.DoUpdate(map, true); while (areaSpawnerEnumerator.MoveNext()) { yield return(null); } //TODO: 1、计算area的直径 2、计算所有unit的直径 3、算出推荐格子大小 对应层AABB范围 //如果大于等于Area直径的90%以上的unit数量大于0 算一个层 Bounds areaAABB = exportArea.GetAABB(); float areaDiameter = Mathf.Max(areaAABB.size.x, areaAABB.size.y, areaAABB.size.z); float consultDiameter = areaDiameter * 0.9f; CalcuateLayer(map, exportArea, areaDiameter); EditorUtility.SetDirty(m_EditorSplitAreaSetting); GameObject.DestroyImmediate(exportArea.gameObject); } EditorUtility.ClearProgressBar(); if (showDialog) { EditorUtility.DisplayDialog("Analyze", "分析成功", "OK"); } AssetDatabase.Refresh(); }
protected override IEnumerator DoExport() { DontDestroyAtExport[] exports = UnityEngine.Object.FindObjectsOfType <DontDestroyAtExport>(); if (exports != null && exports.Length > 0) { for (int iExport = 0; iExport < exports.Length; iExport++) { DontDestroyAtExport export = exports[iExport]; export.gameObject.SetActive(false); } } yield return(null); List <AreaSpawner> areaSpawners = m_Map.GetAreaSpawnerList(); if (areaSpawners != null && areaSpawners.Count > 0) { for (int iArea = 0; iArea < areaSpawners.Count; iArea++) { AreaSpawner areaSpawner = areaSpawners[iArea]; IEnumerator areaUpdateEnum = areaSpawner.DoUpdate(m_Map, false); while (areaUpdateEnum.MoveNext()) { yield return(null); } } } IEnumerator loadAllAreaEnumerator = m_Map.LoadAllArea(true); while (loadAllAreaEnumerator.MoveNext()) { yield return(null); } IEnumerator export3DNavMeshEnum = EditorGamingMapData.Export3DNavMesh(m_SceneCutSize, m_Map); while (export3DNavMeshEnum.MoveNext()) { yield return(null); } }
protected override IEnumerator DoExport() { List <AreaSpawner> areaSpawners = m_Map.GetAreaSpawnerList(); if (areaSpawners != null && areaSpawners.Count > 0) { for (int iArea = 0; iArea < areaSpawners.Count; iArea++) { AreaSpawner areaSpawner = areaSpawners[iArea]; IEnumerator areaUpdateEnum = areaSpawner.DoUpdate(m_Map, false); while (areaUpdateEnum.MoveNext()) { yield return(null); } } } IEnumerator loadAreaEnumerator = m_Map.LoadAllArea(); while (loadAreaEnumerator.MoveNext()) { yield return(null); } EditorCollider outData = new EditorCollider(); List <EditorDecorate> editorDecorateList = new List <EditorDecorate>(); m_AutoId = 1; IEnumerator residentColliderEnumerator = GenerateAreaDecorate(outData, editorDecorateList); while (residentColliderEnumerator.MoveNext()) { yield return(null); } //常驻collider导出 editorDecorateList.Clear(); IEnumerator areaColliderEnumerator = GenerateResidentDecorate(editorDecorateList); while (areaColliderEnumerator.MoveNext()) { yield return(null); } outData.mapID = m_Map.Uid; outData.commondecorateList = editorDecorateList.ToArray(); EditorGamingMapData.SaveColliderToJson(outData); yield return(null); Area[] areaArray = UnityEngine.Object.FindObjectsOfType <Area>(); if (areaArray != null && areaArray.Length > 0) { for (int iArea = areaArray.Length - 1; iArea >= 0; iArea--) { GameObject.DestroyImmediate(areaArray[iArea].gameObject); if (iArea % 10 == 0) { yield return(null); } } } }