/// <summary> /// 获取所有的Map路径 /// </summary> /// <returns></returns> public static List <string> GetMapScenePath() { List <string> mapPaths = new List <string>(); string mapScenePath = ""; MapEditorSetting mapSetting = MapEditorUtility.GetMapEditorSetting(); if (mapSetting != null) { mapScenePath = mapSetting.m_MapSavePath; } string[] mapPathArray = AssetDatabase.FindAssets("t:Scene", new string[] { mapScenePath }); if (mapPathArray != null && mapPathArray.Length > 0) { for (int iMap = 0; iMap < mapPathArray.Length; iMap++) { string assetPath = AssetDatabase.GUIDToAssetPath(mapPathArray[iMap]); string[] pathSplit = assetPath.Split('/'); if (pathSplit != null && pathSplit.Length > 0) { if (pathSplit[pathSplit.Length - 1].Contains("Map_")) { mapPaths.Add(assetPath); } } } } return(mapPaths); }
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); } }
private void OnEnable() { m_MapSetting = MapEditorUtility.GetMapEditorSetting(); m_MapTempletePath = m_MapSetting.m_MapTempletePath; m_MapSavePath = m_MapSetting.m_MapSavePath; m_AreaSpawnerTempletePath = m_MapSetting.m_AreaSpawnerTempletePath; }
private void OnEnable() { m_SelectTypeIndex = 0; if (m_RelationSceneList == null) { m_RelationSceneList = new List <string>(); } m_RelationSceneList.Clear(); string mapScenePath = ""; MapEditorSetting mapSetting = MapEditorUtility.GetMapEditorSetting(); if (mapSetting != null) { mapScenePath = mapSetting.m_MapSavePath; } string[] mapPathArray = AssetDatabase.FindAssets("t:Scene", new string[] { mapScenePath }); if (mapPathArray != null && mapPathArray.Length > 0) { for (int iMap = 0; iMap < mapPathArray.Length; iMap++) { string assetPath = AssetDatabase.GUIDToAssetPath(mapPathArray[iMap]); string[] pathSplit = assetPath.Split('/'); if (pathSplit != null && pathSplit.Length > 0) { if (pathSplit[pathSplit.Length - 1].Contains("Map_")) { m_RelationSceneList.Add(assetPath); } } } } }
public void InitMapUids() { _MapUids = new List <uint>(); MapEditorSetting mapEditorSetting = MapEditorUtility.GetMapEditorSetting(); string[] mapPathArray = AssetDatabase.FindAssets("t:Scene", new string[] { mapEditorSetting != null ? mapEditorSetting.m_MapSavePath : "" }); if (mapPathArray == null) { return; } for (int iMap = 0; iMap < mapPathArray.Length; iMap++) { string assetPath = AssetDatabase.GUIDToAssetPath(mapPathArray[iMap]); string[] pathSplitArray = assetPath.Split('/'); if (pathSplitArray.Length == 0) { continue; } string pathSplit = pathSplitArray[pathSplitArray.Length - 1]; if (!pathSplit.Contains("Map_")) { continue; } pathSplit = pathSplit.Replace(".unity", ""); string[] splitPath = pathSplit.Split('/'); if (splitPath.Length == 0) { continue; } string showPath = splitPath[splitPath.Length - 1]; if (string.IsNullOrEmpty(showPath)) { continue; } string[] showPathArray = showPath.Split('_'); if (showPathArray.Length != 2) { continue; } if (uint.TryParse(showPathArray[1], out uint result) && result > 0) { _MapUids.Add(result); } } }
private string GetMapScenePath() { string sceneName = ""; MapEditorSetting mapSetting = MapEditorUtility.GetMapEditorSetting(); if (mapSetting != null) { sceneName = mapSetting.m_MapSavePath; } string scenePath = string.Format("{0}\\Map_{1}.unity" , sceneName , this.m_MapId); scenePath = scenePath.Replace("\\", "/"); return(scenePath); }
/// <summary> /// 初始化 /// </summary> public void Init() { m_GamingSetting = GamingMapEditorUtility.GetGamingMapEditorSetting(); m_MapSetting = MapEditorUtility.GetMapEditorSetting(); m_SelectIndex = -1; m_GuiStyle = new GUIStyle(); m_GuiStyle.fontSize = 20; m_GuiStyle.fontStyle = FontStyle.BoldAndItalic; m_GuiContentArray = new GUIContent[] { new GUIContent("创建地图配置"), new GUIContent("打开地图配置列表"),new GUIContent("创建地图") }; m_GamingMapPath = m_GamingSetting.m_GamingMapPath; m_GamingMapTemplete = m_GamingSetting.m_GamingMapTemplete; m_GamingAreaTemplete = m_GamingSetting.m_GamingAreaTemplete; m_ConfigPath = m_GamingSetting.m_ConfigPath; m_JsonPath = m_GamingSetting.m_JsonPath; m_CreatureTempletePath = m_GamingSetting.m_CreatureTempletePath; m_LocationTempletePath = m_GamingSetting.m_LocationTempletePath; m_LeapTempletePath = m_GamingSetting.m_LeapTempletePath; m_TriggerTempletePath = m_GamingSetting.m_TriggerTempletePath; m_MaxShipPath = m_GamingSetting.m_MaxShipPath; m_StarMapPath = m_GamingSetting.m_StarMapPath; m_SpacecraftPropertyPath = m_GamingSetting.m_SpacecraftPropertyPath; m_MapTempletePath = m_MapSetting.m_MapTempletePath; m_TreasurePrefabSavePath = m_MapSetting.m_TreasurePrefabSavePath; m_MapSavePath = m_MapSetting.m_MapSavePath; m_AreaSpawnerTempletePath = m_MapSetting.m_AreaSpawnerTempletePath; m_ColliderSavePath = m_MapSetting.m_ColliderSavePath; m_ColliderSavePathCopy = m_MapSetting.m_ColliderSavePathCopy; m_MineralPrefabSavePath = m_MapSetting.m_MineralPrefabSavePath; /*m_GamingMapPath = PlayerPrefsUtility.GetString(Constants.GAMINGMAP_SAVE_PATH); m_GamingMapTemplete = PlayerPrefsUtility.GetString(Constants.GAMINGMAP_TEMPLETE_PATH); m_GamingAreaTemplete = PlayerPrefsUtility.GetString(Constants.GAMINGAREA_TEMPLETE_PATH); m_ConfigPath = PlayerPrefsUtility.GetString(Constants.CONFIG_PATH); m_JsonPath = PlayerPrefsUtility.GetString(Constants.SAVEJSON_PATH); m_CreatureTempletePath = PlayerPrefsUtility.GetString(Constants.CREATURE_TEMPLETE_PATH); m_LocationTempletePath = PlayerPrefsUtility.GetString(Constants.LOCATION_TEMPLETE_PATH); m_MapTempletePath = PlayerPrefsUtility.GetString(Constants.MAP_TEMPLETE_PATH); m_MapSavePath = PlayerPrefsUtility.GetString(Constants.MAP_SAVE_PATH); m_AreaSpawnerTempletePath = PlayerPrefsUtility.GetString(Constants.AREASPAWNER_TEMPLETE_PATH);*/ }
private void OnGUI() { m_GamingSetting = GamingMapEditorUtility.GetGamingMapEditorSetting(); m_MapSetting = MapEditorUtility.GetMapEditorSetting(); GUILayout.BeginVertical(); m_SelectIndex = GUILayout.SelectionGrid(m_SelectIndex, m_GuiContentArray,2,GUILayout.Height(100)); OnClickGrid(m_SelectIndex); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("GamingMap设置:", m_GuiStyle); GUILayout.Space(5); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("GamingMap保存路径:", m_GamingMapPath); //GUILayout.FlexibleSpace(); if (GUILayout.Button("选择")) { m_GamingMapPath = MapEditorUtility.OpenFloderPanel(); m_GamingMapPath = MapEditorUtility.GetRelativePath(m_GamingMapPath); m_GamingSetting.m_GamingMapPath = m_GamingMapPath; //PlayerPrefsUtility.SetString(Constants.GAMINGMAP_SAVE_PATH, m_GamingMapPath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("GamingMap模板:", m_GamingMapTemplete); if (GUILayout.Button("选择")) { m_GamingMapTemplete = MapEditorUtility.OpenFilePanel("", "unity"); m_GamingMapTemplete = MapEditorUtility.GetRelativePath(m_GamingMapTemplete); m_GamingSetting.m_GamingMapTemplete = m_GamingMapTemplete; //PlayerPrefsUtility.SetString(Constants.GAMINGMAP_TEMPLETE_PATH, m_GamingMapTemplete); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("GamingMapArea模板",m_GamingAreaTemplete); if(GUILayout.Button("选择")) { m_GamingAreaTemplete = MapEditorUtility.OpenFilePanel("", "prefab"); m_GamingAreaTemplete = MapEditorUtility.GetRelativePath(m_GamingAreaTemplete); m_GamingSetting.m_GamingAreaTemplete = m_GamingAreaTemplete; //PlayerPrefsUtility.SetString(Constants.GAMINGAREA_TEMPLETE_PATH, m_GamingAreaTemplete); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("配置表路径", m_ConfigPath); if (GUILayout.Button("选择")) { m_ConfigPath = MapEditorUtility.OpenFloderPanel(""); m_ConfigPath = MapEditorUtility.GetRelativePath(m_ConfigPath); m_GamingSetting.m_ConfigPath = m_ConfigPath; //PlayerPrefsUtility.SetString(Constants.CONFIG_PATH, m_ConfigPath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("Json保存路径", m_JsonPath); if (GUILayout.Button("选择")) { m_JsonPath = MapEditorUtility.OpenFloderPanel(""); m_JsonPath = MapEditorUtility.GetRelativePath(m_JsonPath); m_GamingSetting.m_JsonPath = m_JsonPath; //PlayerPrefsUtility.SetString(Constants.SAVEJSON_PATH, m_JsonPath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("Creature模板", m_CreatureTempletePath); if (GUILayout.Button("选择")) { m_CreatureTempletePath = MapEditorUtility.OpenFilePanel("","prefab"); m_CreatureTempletePath = MapEditorUtility.GetRelativePath(m_CreatureTempletePath); m_GamingSetting.m_CreatureTempletePath = m_CreatureTempletePath; //PlayerPrefsUtility.SetString(Constants.CREATURE_TEMPLETE_PATH, m_CreatureTempletePath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("Location模板", m_LocationTempletePath); if (GUILayout.Button("选择")) { m_LocationTempletePath = MapEditorUtility.OpenFilePanel("", "prefab"); m_LocationTempletePath = MapEditorUtility.GetRelativePath(m_LocationTempletePath); m_GamingSetting.m_LocationTempletePath = m_LocationTempletePath; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("Leap模板", m_LeapTempletePath); if (GUILayout.Button("选择")) { m_LeapTempletePath = MapEditorUtility.OpenFilePanel("", "prefab"); m_LeapTempletePath = MapEditorUtility.GetRelativePath(m_LeapTempletePath); m_GamingSetting.m_LeapTempletePath = m_LeapTempletePath; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("Trigger模板", m_TriggerTempletePath); if (GUILayout.Button("选择")) { m_TriggerTempletePath = MapEditorUtility.OpenFilePanel("", "prefab"); m_TriggerTempletePath = MapEditorUtility.GetRelativePath(m_TriggerTempletePath); m_GamingSetting.m_TriggerTempletePath = m_TriggerTempletePath; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("最大战舰", m_MaxShipPath); if (GUILayout.Button("选择")) { m_MaxShipPath = MapEditorUtility.OpenFilePanel("", "prefab"); m_MaxShipPath = MapEditorUtility.GetRelativePath(m_MaxShipPath); m_GamingSetting.m_MaxShipPath = m_MaxShipPath; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("星图保存路径", m_StarMapPath); if (GUILayout.Button("选择")) { m_StarMapPath = MapEditorUtility.OpenFloderPanel(""); m_StarMapPath = MapEditorUtility.GetRelativePath(m_StarMapPath); m_GamingSetting.m_StarMapPath = m_StarMapPath; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("战舰属性保存路径", m_SpacecraftPropertyPath); if (GUILayout.Button("选择")) { m_SpacecraftPropertyPath = MapEditorUtility.OpenFloderPanel(""); m_SpacecraftPropertyPath = MapEditorUtility.GetRelativePath(m_SpacecraftPropertyPath); m_GamingSetting.m_SpacecraftPropertyPath = m_SpacecraftPropertyPath; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(20); //Map的相关配置 GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Map设置:", m_GuiStyle); GUILayout.Space(5); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("地图模板路径", m_MapTempletePath); if (GUILayout.Button("选择")) { m_MapTempletePath = MapEditorUtility.OpenFilePanel("", "unity"); m_MapTempletePath = MapEditorUtility.GetRelativePath(m_MapTempletePath); m_MapSetting.m_MapTempletePath = m_MapTempletePath; //PlayerPrefsUtility.SetString(Constants.MAP_TEMPLETE_PATH, m_MapTempletePath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("地图保存路径:", m_MapSavePath); if (GUILayout.Button("选择")) { m_MapSavePath = MapEditorUtility.OpenFloderPanel(); m_MapSavePath = MapEditorUtility.GetRelativePath(m_MapSavePath); m_MapSetting.m_MapSavePath = m_MapSavePath; //PlayerPrefsUtility.SetString(Constants.MAP_SAVE_PATH, m_MapSavePath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("AreaSpawner模板路径:", m_AreaSpawnerTempletePath); if (GUILayout.Button("选择")) { m_AreaSpawnerTempletePath = MapEditorUtility.OpenFilePanel("", "prefab"); m_AreaSpawnerTempletePath = MapEditorUtility.GetRelativePath(m_AreaSpawnerTempletePath); m_MapSetting.m_AreaSpawnerTempletePath = m_AreaSpawnerTempletePath; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("碰撞体保存路径:", m_ColliderSavePath); if (GUILayout.Button("选择")) { m_ColliderSavePath = MapEditorUtility.OpenFloderPanel(""); m_ColliderSavePath = MapEditorUtility.GetRelativePath(m_ColliderSavePath); m_MapSetting.m_ColliderSavePath = m_ColliderSavePath; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("碰撞体备份保存路径:", m_ColliderSavePathCopy); if (GUILayout.Button("选择")) { m_ColliderSavePathCopy = MapEditorUtility.OpenFloderPanel(""); m_ColliderSavePathCopy = MapEditorUtility.GetRelativePath(m_ColliderSavePathCopy); m_MapSetting.m_ColliderSavePathCopy = m_ColliderSavePathCopy; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("寻宝预设保存路径:", m_TreasurePrefabSavePath); if (GUILayout.Button("选择")) { m_TreasurePrefabSavePath = MapEditorUtility.OpenFloderPanel(""); m_TreasurePrefabSavePath = MapEditorUtility.GetRelativePath(m_TreasurePrefabSavePath); m_MapSetting.m_TreasurePrefabSavePath = m_TreasurePrefabSavePath; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("挖矿预设保存路径:", m_MineralPrefabSavePath); if (GUILayout.Button("选择")) { m_MineralPrefabSavePath = MapEditorUtility.OpenFloderPanel(""); m_MineralPrefabSavePath = MapEditorUtility.GetRelativePath(m_MineralPrefabSavePath); m_MapSetting.m_MineralPrefabSavePath = m_MineralPrefabSavePath; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndVertical(); EditorUtility.SetDirty(m_MapSetting); EditorUtility.SetDirty(m_GamingSetting); }