Example #1
0
        void BottomToolBar(Rect rect)
        {
            GUILayout.BeginArea(rect);

            using (new EditorGUILayout.HorizontalScope())
            {
                var style = "miniButton";
                if (GUILayout.Button("Expand All", style))
                {
                    treeView.ExpandAll();
                }

                if (GUILayout.Button("Collapse All", style))
                {
                    treeView.CollapseAll();
                }

                GUILayout.FlexibleSpace();

                GUILayout.Label(m_TreeAsset != null ? AssetDatabase.GetAssetPath(m_TreeAsset) : string.Empty);

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Add Item", style))
                {
                    Undo.RecordObject(m_TreeAsset, "Add Item To Asset");

                    // Add item as child of selection
                    var               selection = m_TreeView.GetSelection();
                    TreeElement       parent    = (selection.Count == 1 ? m_TreeView.treeModel.Find(selection[0]) : null) ?? m_TreeView.treeModel.root;
                    int               depth     = parent != null ? parent.depth + 1 : 0;
                    int               id        = m_TreeView.treeModel.GenerateUniqueID();
                    DialogTreeElement element   = new DialogTreeElement(string.Format("Item{0}", id), depth, id);
                    m_TreeView.treeModel.AddElement(element, parent, 0);
                    DialogNodeGraph dialogNodeGraph = CreateInstance <DialogNodeGraph>();
                    AssetDatabase.CreateAsset(dialogNodeGraph, string.Format("Assets/{0}.asset", id));
                    AssetDatabase.Refresh();
                    element.DialogNodeGraph = dialogNodeGraph;
                    // Select newly created element
                    m_TreeView.SetSelection(new[] { id }, TreeViewSelectionOptions.RevealAndFrame);
                }

                if (GUILayout.Button("Remove Item", style))
                {
                    Undo.RecordObject(m_TreeAsset, "Remove Item From Asset");
                    IList <int> elementIDs             = m_TreeView.GetSelection();
                    IList <DialogTreeElement> elements = m_TreeView.treeModel.GetData().Where(element => elementIDs.Contains(element.id)).ToArray();
                    foreach (DialogTreeElement item in elements)
                    {
                        DeleAsset(item);
                    }
                    m_TreeView.treeModel.RemoveElements(elementIDs);
                    AssetDatabase.Refresh();
                }
            }
            GUILayout.EndArea();
        }
        public override void OnHeaderGUI()
        {
            DialogBaseNode  node  = target as DialogBaseNode;
            DialogNodeGraph graph = node.graph as DialogNodeGraph;

            node.name = node.DialogueName;
            GUILayout.Label(node.DialogueName, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30));
            GUI.color = Color.white;
        }
        public override void OnBodyGUI()
        {
            base.OnBodyGUI();
            SentenceNode    node  = target as SentenceNode;
            DialogNodeGraph graph = node.graph as DialogNodeGraph;

            if (GUILayout.Button("OpenSentenceEdiot"))
            {
                Debug.Log("OpenEditor");
            }
        }
 public static RootNode GetDialogRoot(this DialogNodeGraph dialogNodeGraph)
 {
     foreach (Node item in dialogNodeGraph.nodes)
     {
         if (item is RootNode)
         {
             return((RootNode)item);
         }
     }
     return(null);
 }
Example #5
0
        public override void OnBodyGUI()
        {
            BranchNodeBase  node  = target as BranchNodeBase;
            DialogNodeGraph graph = node.graph as DialogNodeGraph;

            NodeEditorGUILayout.PortField(new GUIContent("Last Dialog"), target.GetInputPort("LastDialog"), GUILayout.MinWidth(0));

            if (node.Branchs.Count == 0)
            {
                GUILayout.BeginHorizontal();
                NodeEditorGUILayout.PortField(new GUIContent("Next Dialog"), target.GetOutputPort("NextDialog"), GUILayout.MinWidth(0));
                GUILayout.EndHorizontal();
            }

            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("DialogueName"), new GUIContent("Dialogue Name"));
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("canReturn"), new GUIContent("Can Return"));

            GUILayout.Space(5);

            NodeEditorGUILayout.DynamicPortList("Branchs", typeof(DialogBaseNode), serializedObject, NodePort.IO.Output, Node.ConnectionType.Override);
        }
Example #6
0
    //!Otwiera okno edytora i dodaje tą opcje do paska edytora Unity.
    public static void openWindow()
    {
        DialogNodeGraph window = GetWindow <DialogNodeGraph>();

        window.titleContent = new GUIContent("Dialog Node Graph.");
    }