Commit 52ad2aa7 by Alisa Jung

can specify which level to load in xml editor.

parent 7b6d1325
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using System;
public class XmlLevelEditor : EditorWindow { public class XmlLevelEditor : EditorWindow {
...@@ -7,6 +8,8 @@ public class XmlLevelEditor : EditorWindow { ...@@ -7,6 +8,8 @@ public class XmlLevelEditor : EditorWindow {
DeserializedLevelsSaver deserializedLevelsSaver; DeserializedLevelsSaver deserializedLevelsSaver;
DeserializedLevelsCrossChecker deserializedLevelsCrossChecker; DeserializedLevelsCrossChecker deserializedLevelsCrossChecker;
private string levelToLoad = "0";
[MenuItem("Window/Xml Level Editor")] [MenuItem("Window/Xml Level Editor")]
public static void ShowWindow() public static void ShowWindow()
{ {
...@@ -26,13 +29,28 @@ public class XmlLevelEditor : EditorWindow { ...@@ -26,13 +29,28 @@ public class XmlLevelEditor : EditorWindow {
GUILayout.Label ("Import", EditorStyles.boldLabel); GUILayout.Label ("Import", EditorStyles.boldLabel);
GUILayout.Label ("Import Levels.xml into the scene"); GUILayout.Label ("Import Levels.xml into the scene");
GUILayout.Label("Level to load: ");
levelToLoad = GUILayout.TextField(levelToLoad);
if (GUILayout.Button("Import Levels.xml")) if (GUILayout.Button("Import Levels.xml"))
{ {
int levelIndex = 0;
try
{
levelIndex = System.Convert.ToInt32(levelToLoad);
}
catch (FormatException e){
Debug.LogWarning("Keine gltige Zahl eingegeben. Lade Level 0");
}
catch(OverflowException e2){
Debug.LogWarning("Keine gltige Zahl eingegeben. Lade Level 0");
}
deserializedLevelsLoader.load(); deserializedLevelsLoader.load();
deserializedLevelsLoader.loadLevel(); deserializedLevelsLoader.loadLevel(levelIndex);
} }
// Export section // Export section
GUILayout.Label ("Export", EditorStyles.boldLabel); GUILayout.Label ("Export", EditorStyles.boldLabel);
GUILayout.Label ("Export children of \"" + DeserializedLevelsSaver.xmlItemsToExportGOName +"\" GameObject into " + DeserializedLevelsSaver.xmlItemsToExportGOName +".xml", EditorStyles.wordWrappedLabel); GUILayout.Label ("Export children of \"" + DeserializedLevelsSaver.xmlItemsToExportGOName +"\" GameObject into " + DeserializedLevelsSaver.xmlItemsToExportGOName +".xml", EditorStyles.wordWrappedLabel);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment