void AddNewNode() { if (_newDKey == null || _newDKey == "" || _newStrKey == null || _newStrKey == "") { Debug.Log("Can't add new node. Invalid dialog ID key and/or string ID key."); return; } DialogNode newNode = new DialogNode(_newDKey, _newStrKey); if (dm.Graph.Contains(newNode)) { Debug.Log("Dialog ID key already exist! Please enter another key."); return; } dm.Graph.Add(newNode); LanguageController.Instance.AddWord(_newStrKey, _newdialog); DialogNodeGUI newNodeWindow = CreateInstance <DialogNodeGUI>(); int newWindowId = nodeWindows[nodeWindows.Count - 1].WindowId + 1; newNodeWindow.init(newNode, newWindowId, new Vector2(100, 100)); windows.Add(newNodeWindow.Shape); nodeWindows.Add(newNodeWindow); windows[windows.Count - 1] = GUILayout.Window(newNodeWindow.WindowId, windows[windows.Count - 1], newNodeWindow.DrawNodeWindow, newNodeWindow.Node.StrKey); }
void BuildNodeWindows() { int nodeId = 0; foreach (KeyValuePair <string, DialogNode> n in dm.Graph.Nodes) { DialogNode node = n.Value; // don't build a window for a response dialog because it's included in a dialog node window if (node.GetType() == typeof(ResponseNode)) { continue; } DialogNodeGUI dngui = CreateInstance <DialogNodeGUI>(); dngui.init(node, nodeId, new Vector2(nodeId % ((1000 - sideWindowWidth) / 220) * 220, nodeId / ((1000 - sideWindowWidth) / 220) * 120)); nodeWindows.Add(dngui); windows.Add(dngui.Shape); ++nodeId; } }