public void ExportStarMap() { if (m_StarMapVoList != null && m_StarMapVoList.Count > 0) { EditorStarMap starMapData = new EditorStarMap(); List <EditorFixedStar> fixedStars = new List <EditorFixedStar>(); List <EditorPlanet> planets = new List <EditorPlanet>(); List <EditorStarMapArea> planetAreas = new List <EditorStarMapArea>(); FixedStarElement element = null; for (int iStar = 0; iStar < m_StarMapVoList.Count; iStar++) { StarMapVO starMapVo = m_StarMapVoList[iStar]; EditorFixedStar fixedStar = new EditorFixedStar(); fixedStars.Add(fixedStar); fixedStar.fixedStarId = starMapVo.FixedStarid; fixedStar.fixedStarName = starMapVo.Name; fixedStar.fixedStarRes = starMapVo.AssetName; fixedStar.relations = starMapVo.Relation_Id; element = m_StarMapMainPanel.GetElement(starMapVo.FixedStarid); if (element != null) { fixedStar.position = new EditorPosition2D(element.GetPosition()); } planets.Clear(); SavePlanet(planets, starMapVo.FixedStarid, planetAreas, fixedStar); fixedStar.planetList = planets.ToArray(); } starMapData.fixedStars = fixedStars.ToArray(); EditorGamingMapData.SaveStarMapToJson(starMapData); } }
public void LoadStarMap() { EditorStarMap starMap = EditorGamingMapData.LoadStarMap(); if (starMap == null) { return; } m_PreviewStarMap = starMap; InitPanels(true); }
private void InitEditor() { m_PreviewStarMap = null; EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyGUI; EditorApplication.update += DoUpdate; m_DoUpdateEnumerator = DoEditorUpdate(); m_AllGamingMaps = EditorGamingMapData.LoadAllDeapSpaceMapJson(); EditorGamingMapData.LoadStarMapVO(); m_StarMapVoList = ConfigVO <StarMapVO> .Instance.GetList(); InitPanels(); }
/// <summary> /// 刷新npc列表显示ui /// </summary> /// <param name="contentList"></param> /// <param name="areaSpawner"></param> private void RefreshStarMapRootUI(StarMapEditorRoot starMapRoot) { if (starMapRoot == null) { return; } m_ContentCache.Clear(); m_ContentCache.Add(new GUIContent("打开星图面板")); m_ContentCache.Add(new GUIContent("保存")); m_ContentCache.Add(new GUIContent("导出json")); m_ContentCache.Add(new GUIContent("导入json")); m_ContentCache.Add(new GUIContent("重置")); Vector2 mousePosition = Event.current.mousePosition; GameObject userData = Selection.activeGameObject; int selected = -1; EditorUtility.DisplayCustomMenu(new Rect(mousePosition.x, mousePosition.y, 0, 0), m_ContentCache.ToArray(), selected, delegate(object data, string[] opt, int select) { switch (select) { case 0: starMapRoot.OpenStarMap(); break; case 1: EditorSceneManager.SaveOpenScenes(); break; case 2: //导出json starMapRoot.ExportStarMap(); break; case 3: //导入json starMapRoot.LoadStarMap(); break; case 4: //初始化 m_PreviewStarMap = null; InitPanels(true); break; } }, userData); Event.current.Use(); }
public override void InitData(ByteBuffer byteBuffer) { m_Config = JsonUtility.FromJson <EditorStarMap>(System.Text.Encoding.UTF8.GetString(byteBuffer.ToSizedArray())); m_Config.Init(); }