public static void SaveDialogue(string path, DialogueSystemContainer dsContainer) { var serializer = new XmlSerializer(typeof(DialogueSystemContainer)); var encoding = Encoding.GetEncoding("UTF-8"); using (var stream = new StreamWriter(path, false, encoding)) { serializer.Serialize(stream, dsContainer); } }
private void DrawBody() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); if (dsContainer == null) { dsContainer = new DialogueSystemContainer { Chapters = new List <Chapter>() }; } if (GUILayout.Button("Add Chapter", GUILayout.MaxWidth(160))) { dsContainer.Chapters.Add(new Chapter { ID = "ChapterID", Scenes = new List <Scene>() }); foldouts.Add(false); } if (GUILayout.Button("Remove Last Chapter", GUILayout.MaxWidth(160))) { if (dsContainer.Chapters.Count > 0) { var lastChapter = dsContainer.Chapters.Count - 1; dsContainer.Chapters.RemoveAt(lastChapter); foldouts.RemoveAt(lastChapter); } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.MaxWidth(1920)); chapterLayout.DrawChapters(dsContainer.Chapters, foldouts); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }
private void LoadPrompt() { var path = EditorUtility.OpenFilePanel( "Select File", Application.streamingAssetsPath, "xml" ); if (path.Length != 0) { dsContainer = SavingSystem.LoadDialogue(path); foldouts = new List <bool>(); foreach (var chapter in dsContainer.Chapters) { foldouts.Add(false); } } }