/** 写回 */ public void write() { Ctrl.print("保存场景", config.id); if (_stream == null) { _stream = new BytesWriteStream(); } else { _stream.clear(); } _stream.writeLen(elements.size()); foreach (int k in elements.getSortedKeyList()) { ScenePlaceElementConfig scenePlaceElementConfig = elements.get(k).config; scenePlaceElementConfig.writeBytesSimple(_stream); } string path = SceneEditorWindow.getScenePlaceFilePath(config.id); FileUtils.writeFileForBytesWriteStream(path, _stream); }
//导入阻挡 static public void Importobstacle(bool idDefault = false) { string path = ""; CheckDirectory(); if (idDefault == true) { path = ms_sSaveString + "/" + ms_SceneName + m_sObstacleLastName + ".dat"; } else { path = EditorUtility.OpenFilePanel("导入场景阻挡文件", ms_sSaveString, "dat"); if (path == "") { return; } } if (path.IndexOf(m_sObstacleLastName) == -1) { SceneEditorWindow.DialogReturn("文件选择错误", "文件错误,阻挡文件应该包含 (" + m_sObstacleLastName + ".dat ) ,请重新进行导入操作!", true); return; } //检查文件是否存在, 不存在直接断掉 if (!File.Exists(path)) { return; } EditerDataClass._Instance.Importobstacle(path); }
static void Init() { if (_windowInstance == null) { _windowInstance = EditorWindow.GetWindow(typeof(SceneEditorWindow)) as SceneEditorWindow; _windowInstance._delegate = new SceneView.OnSceneFunc(OnSceneFunc); SceneView.onSceneGUIDelegate += _windowInstance._delegate; } }
private static void callNative(NavMeshConfig config, SceneRecastData data, int currentMapID) { BytesWriteStream stream = new BytesWriteStream(); stream.setUseBitBoolean(false); config.write(stream); string cStr = ShineToolGlobal.mapInfoPath + "/navConfig.bin"; string dStr = SceneEditorWindow.getMapFilePathFront(currentMapID) + "_navData.bin"; string objStr = SceneEditorWindow.getMapFilePathFront(currentMapID) + "_navData.obj"; FileUtils.writeFileForBytesWriteStream(cStr, stream); stream.clear(); data.write(stream); FileUtils.writeFileForBytesWriteStream(dStr, stream); if (_needObjFile) { StringBuilder sb = new StringBuilder(); foreach (Vector3 vec in data.vertices) { sb.Append('v'); sb.Append(' '); sb.Append(vec.x); sb.Append(' '); sb.Append(vec.y); sb.Append(' '); sb.Append(vec.z); sb.Append('\n'); } int[] navIndices = data.triangles.getValues(); int len = data.triangles.size() / 3; for (int i = 0; i < len; i++) { sb.Append('f'); sb.Append(' '); sb.Append(navIndices[i * 3] + 1); sb.Append(' '); sb.Append(navIndices[i * 3 + 1] + 1); sb.Append(' '); sb.Append(navIndices[i * 3 + 2] + 1); sb.Append('\n'); } FileUtils.writeFileForUTF(objStr, sb.ToString()); } Ctrl.print("callJar"); ToolFileUtils.executeServerTool("exportNav", currentMapID.ToString()); Ctrl.print("OK"); }
public static void CreateDungeonEditor() { if (SceneEditorWindow.instance) { DestroyImmediate(SceneEditorWindow.instance); } SceneEditorWindow.instance = ScriptableObject.CreateInstance <SceneEditorWindow>(); SceneEditorWindow.instance.name = "Dungeon Editor"; SceneCache.Init(); SceneView.FrameLastActiveSceneView(); }
void DrawWayPoint(ref int childCount, LinkedList <Vector2> WayPointarray) { SceneEditorWindow.StartSpace(2, 15); childCount = childCount + WayPointarray.Count; int index = 1; foreach (var item in WayPointarray) { GUILayout.Label("路径点: " + (index++).ToString() + " X: " + item.x.ToString() + " Y: " + item.y.ToString()); } SceneEditorWindow.EndSpace(); }
private static bool OpenAsset(int instanceid, int line) { UnityEngine.Object @object = EditorUtility.InstanceIDToObject(instanceid); if (@object is SceneCache && EditorUtility.DisplayDialog("", string.Format("用副本编辑器打开 {0}?", @object.name), "Hm", "Cancle")) { SceneCache.LoadAsset(AssetDatabase.GetAssetPath(@object)); SceneUtils.OpenScene(); SceneEditorWindow.CreateDungeonEditor(); return true; } return false; }
void DrawTotalInfo() { mb_TotalInfo = EditorGUILayout.Foldout(mb_TotalInfo, "统计信息"); if (mb_TotalInfo) { SceneEditorWindow.StartSpace(1, 15); mb_MonsterTotalInfo = EditorGUILayout.Foldout(mb_MonsterTotalInfo, "场景点统计信息"); if (mb_MonsterTotalInfo) { SceneEditorWindow.StartSpace(1, 20); GUILayout.Space(2); //DrawTotalMonsterBorn(InteractionTool.GetBornParent()); SceneEditorWindow.EndSpace(); } mb_FixMonsterTotalInfo = EditorGUILayout.Foldout(mb_FixMonsterTotalInfo, "定点统计信息"); if (mb_FixMonsterTotalInfo) { SceneEditorWindow.StartSpace(1, 15); EditorGUILayout.BeginHorizontal(); DrawId("I D", 50, 0); DrawName("名 字", 90, -5); DrawLv("数 量", 55, -5); EditorGUILayout.EndHorizontal(); GUILayout.Space(2); DrawTotalBorn(InteractionTool.GetDCBornTotalNumber()); SceneEditorWindow.EndSpace(); } mb_OBjTotalInfo = EditorGUILayout.Foldout(mb_OBjTotalInfo, "OBJ统计信息"); if (mb_OBjTotalInfo) { SceneEditorWindow.StartSpace(1, 15); EditorGUILayout.BeginHorizontal(); DrawId("I D", 50, 0); DrawName("名 字", 90, -5); DrawLv("数 量", 55, -5); EditorGUILayout.EndHorizontal(); GUILayout.Space(2); DrawTotalBorn(InteractionTool.GetDCObjTotalNumber()); SceneEditorWindow.EndSpace(); } GUILayout.Label("场景所有对象总数:" + " " + (InteractionTool.GetRegionParent().childCount + InteractionTool.GetPointParent().childCount).ToString()); SceneEditorWindow.EndSpace(); } }
private void OnGUI() { GUILayout.BeginArea(new Rect(0f, base.position.height / 3f, base.position.width, base.position.height / 3f)); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("New Dungeon"), new GUILayoutOption[] { GUILayout.Width(100f), GUILayout.Height(60f) })) { string text = EditorUtility.OpenFilePanel("New Dungeon", "Assets/Scene/Test", "unity"); if (!string.IsNullOrEmpty(text) && SceneUtils.CheckScene(text)) { text = text.Replace(Application.dataPath, "Assets"); string text2 = EditorUtility.SaveFilePanel("Save New Dungeon", "Assets", "NewDungeon", "asset"); if (!string.IsNullOrEmpty(text2) && !text2.Contains(Application.dataPath)) { string contents = File.ReadAllText(text2); string arg = text2.Split(new char[] { '/' }).Last<string>(); text2 = string.Format("{0}/DungeonTmp/{1}", Application.dataPath, arg); Debug.Log(text2); File.WriteAllText(text2, contents); } text2 = text2.Replace(Application.dataPath, "Assets"); SceneCache.LoadDungeon(text2, text); SceneUtils.OpenScene(); SceneEditorWindow.CreateDungeonEditor(); this.Destroy(); } else { base.ShowNotification(new GUIContent("Choose .unity")); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); }
static void OpenWindow() { if (Application.isPlaying) { if (_windowInstance == null) { _windowInstance = EditorWindow.GetWindow(typeof(SceneEditorWindow)) as SceneEditorWindow; _windowInstance.Init(); } else { _windowInstance.Focus(); } } else { Debug.LogWarning("请先启动游戏"); } }
//GUI绘制函数, Unity函数 void OnGUI() { if (!Application.isPlaying) { CloseWindow(); } else { EditorGUILayout.BeginHorizontal(); mp_ScroPos = EditorGUILayout.BeginScrollView(mp_ScroPos, false, false); EditorGUILayout.BeginVertical(); mb_FoldMonsterInfo = EditorGUILayout.Foldout(mb_FoldMonsterInfo, "怪物信息"); if (mb_FoldMonsterInfo) { SceneEditorWindow.StartSpace(1, 15); DrawBornInfo(); SceneEditorWindow.EndSpace(); } if (mb_MonsterBorn) { //DrawFixMonstBorninfo(ref mb_MonsterBorn, "范围刷怪点列表", InteractionTool.GetBornParent(), ref mp_MonsterBornPos, m_DCBornDictArray); } if (mb_FixMonsterBorn) { // DrawFixMonstBorninfo(ref mb_FixMonsterBorn, "定点刷怪列表", InteractionTool.GetFixBornParent(), ref mp_FixBornPos, m_DCFixBornDictArray); } if (mb_ObjBorn) { // DrawFixMonstBorninfo(ref mb_ObjBorn, "OBJ列表", InteractionTool.GetObjParent(), ref mp_ObjBornPos, null); } DrawTotalInfo(); EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); EditorGUILayout.EndHorizontal(); } }
void OnGUI() { EditorGUILayout.Space(); mapCell = EditorGUILayout.ObjectField(mapCell, typeof(HexCell), true) as HexCell; cellLabelPrefab = EditorGUILayout.ObjectField(cellLabelPrefab, typeof(Text), true) as Text; chunkPrefab = EditorGUILayout.ObjectField(chunkPrefab, typeof(HexGridChunk), true) as HexGridChunk; noiseSource = EditorGUILayout.ObjectField(noiseSource, typeof(Texture), true) as Texture2D; mapSizeX = EditorGUILayout.IntField("地图长:", mapSizeX); mapSizeY = EditorGUILayout.IntField("地图宽:", mapSizeY); EditorGUILayout.Space(); if (GUILayout.Button("生成地图预览")) { if (mapCell == null) { Debug.LogError("没有地图格子预制体"); return; } GenerateMap(); isCreate = true; } if (isCreate) { for (int i = 0; i < HexMapEditor.HexGrid.chunks.Length; i++) { HexMapEditor.HexGrid.chunks[i].LateRefresh(); } } if (GUILayout.Button("打开怪物资源")) { SceneEditorWindow.CreateDungeonEditor(); } if (GUILayout.Button("打开地图数据编辑")) { HexMapCellTypeWindow.CreateCellTypeEditor(); } if (GUILayout.Button("保存当前场景数据到Json")) { MapEditorData.ExportJSON(); } }
/** 读取数据 */ public void read() { string path = SceneEditorWindow.getScenePlaceFilePath(config.id); BytesReadStream stream = FileUtils.readFileForBytesReadStream(path); if (stream != null) { int len = stream.readLen(); for (int i = 0; i < len; i++) { ScenePlaceElementConfig eConfig = new ScenePlaceElementConfig(); eConfig.readBytesSimple(stream); SceneElementEditorData eData = new SceneElementEditorData(); eData.config = eConfig; elements.put(eData.config.instanceID, eData); } } }
public SceneEditorWindow() { SceneEditorWindow.instance = this; SceneView.onSceneGUIDelegate = (SceneView.OnSceneFunc)Delegate.Combine(SceneView.onSceneGUIDelegate, new SceneView.OnSceneFunc(this.SceneUpdate)); }
static void Init() { SceneEditorWindow window = (SceneEditorWindow)EditorWindow.GetWindow(typeof(SceneEditorWindow)); }
static void clearSceneEditorData() { SceneEditorWindow.clearSceneEditorData(); }