コード例 #1
0
        private void CreateDialogue(string conversationId)
        {
            if (conversationId == string.Empty)
            {
                conversationId = "CON001-NAME";
            }
            DialogueList = new List <DialogueRootObject>();
            var dro = CreateDialogueRoot.Create(dname: conversationId + "-" + DialogueList.Count);

            CurrentDialogue = dro;
            DialogueList.Add(CurrentDialogue);
            Selection.activeObject = CurrentDialogue;
        }
コード例 #2
0
        private void LoadFromFile()
        {
            var absPath = EditorUtility.OpenFilePanel("Select Dialogue List",
                                                      directory: Application.dataPath + "/Dialogue/", extension: "xml");

            if (absPath == string.Empty)
            {
                Debug.LogWarning("No File Selected");
                return;
            }

            var relPath = absPath.Substring(startIndex: Application.dataPath.Length - "Assets".Length);

            if (DialogueList == null)
            {
                DialogueList = new List <DialogueRootObject>();
            }

            DialogueTree tree;

            var serializer = new XmlSerializer(type: typeof(DialogueTree));

            using (Stream reader = new FileStream(relPath, FileMode.Open))
            {
                tree = (DialogueTree)serializer.Deserialize(reader);
            }

            for (var i = 0; i < tree.DialogueRoots.Count - 1; i++)
            {
                var nodes = tree.DialogueRoots[i].DialogueNodes;
                var dro   = CreateDialogueRoot.Create(tree.DialogueRoots[i].Current.ConversationID);
                if (dro.Conversation == null)
                {
                    dro.Conversation = new DialogueRoot();
                }

                foreach (var node in nodes)
                {
                    dro.Conversation.Add(node);
                }
                DialogueList.Add(dro);
                EditorUtility.SetDirty(dro);
                AssetDatabase.SaveAssets();
            }
        }