private void OnSelectionChanged() { var newDialogue = Selection.activeObject as Dialogue.Dialogue; if (newDialogue == null) { return; } if (_toolbar != null) { rootVisualElement.Remove(_toolbar); } _selectedDialogue = newDialogue; Repaint(); _toolbar = new Toolbar(); var button = new Button(() => _selectedDialogue.CreateNode(null)) { text = "Create Node", }; _toolbar.Add(button); rootVisualElement.Add(_toolbar); }
protected override void Save(string savePath) { base.Save(savePath); // When the game will want to read the dialogue it does not care about visual stuff // so we serialize the gameplay info in another file in StreamingAssets Dialogue.Dialogue dialogue = new Dialogue.Dialogue(); string rootNodeID = ""; foreach (DialogueNode node in m_Graph.m_Nodes) { dialogue.AddNode(node.m_Node); if (node.IsRoot()) { Assert.IsTrue(rootNodeID == "", "several root node found, this dialogue is ill formed"); rootNodeID = node.m_ID; } } dialogue.m_RootNodeID = rootNodeID; string filename = Path.GetFileName(savePath); XMLSerializerHelper.Serialize(dialogue, Application.streamingAssetsPath + "/Dialogues/" + filename); }
private void Awake() { animator = GetComponent <Animator>(); currentDialogue = new Dialogue(); }