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; }
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(); }
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(); } }