public bool OnSelectEntry(SearchTreeEntry searchTreeEntry, SearchWindowContext context)
    {
        if (_graphView == null || _editorWindow == null)
        {
            return(false);
        }

        //Get Relative world position of search window in regards to the Editor Window visual element
        Vector2 worldMousePosition = _editorWindow.rootVisualElement.ChangeCoordinatesTo(
            _editorWindow.rootVisualElement.parent, context.screenMousePosition - _editorWindow.position.position);

        // Transform to local coordinates based on GraphView
        Vector2 localMousePosition = _graphView.contentViewContainer.WorldToLocal(worldMousePosition);


        switch (searchTreeEntry.userData)
        {
        case DialogueNode node:
        {
            Debug.Log("Created");
            _graphView.CreateNode("Dialogue Node", localMousePosition);
            return(true);
        }

        default:
        {
            return(false);
        }
        }
    }
Example #2
0
    private void GenerateToolbar()
    {
        var toolbar = new Toolbar();

        var fileNameTextField = new TextField("File Name:");

        fileNameTextField.SetValueWithoutNotify(_fileName);
        fileNameTextField.MarkDirtyRepaint();
        fileNameTextField.RegisterValueChangedCallback(evt => _fileName = evt.newValue);
        toolbar.Add(fileNameTextField);

        toolbar.Add(new Button(() => RequestDataOperation(true))
        {
            text = "Save Data"
        });
        toolbar.Add(new Button(() => RequestDataOperation(false))
        {
            text = "Load Data"
        });

        var nodeCreateButton = new Button(() => {
            _graphView.CreateNode("Dialogue Node");
        });

        nodeCreateButton.text = "Create Node";
        toolbar.Add(nodeCreateButton);

        rootVisualElement.Add(toolbar);
    }
Example #3
0
    private void GenerateToolbar()
    {
        var toolbar = new Toolbar();

        var fileNameTextField = new TextField(label: "File Name:");

        fileNameTextField.SetValueWithoutNotify(_fileName);
        fileNameTextField.MarkDirtyRepaint();
        fileNameTextField.RegisterCallback((EventCallback <ChangeEvent <string> >)(EventType => _fileName = EventType.newValue));
        toolbar.Add(fileNameTextField);

        toolbar.Add(child: new Button(clickEvent: () => SaveData())
        {
            text = "Save Data"
        });
        toolbar.Add(child: new Button(clickEvent: () => LoadData())
        {
            text = "Load Data"
        });

        var nodeCreateButton = new Button(clickEvent: () => { _graphView.CreateNode("Dialogue Node"); });

        nodeCreateButton.text = "Creat Node";
        toolbar.Add(nodeCreateButton);

        rootVisualElement.Add(toolbar);
    }
    private void GenerateToolBar()
    {
        var toolbar = new Toolbar();
        var button  = new Button(() => {
            _graphView.CreateNode("Dialogue Node");
        });

        button.text = "Create Node";
        toolbar.Add(button);
        rootVisualElement.Add(toolbar);
    }
Example #5
0
    public bool OnSelectEntry(SearchTreeEntry SearchTreeEntry, SearchWindowContext context)
    {
        var worldMousePosition = _window.rootVisualElement.ChangeCoordinatesTo(_window.rootVisualElement.parent, context.screenMousePosition - _window.position.position);
        var localMousePosition = _graphView.contentViewContainer.WorldToLocal(worldMousePosition);

        switch (SearchTreeEntry.userData)
        {
        case DialogueNode dialogueNode:
            _graphView.CreateNode("Dialogue Node", localMousePosition);
            return(true);

        default:
            return(false);
        }
    }
Example #6
0
    private static void GenerateDialogueNodes(DialogueGraphView graphView, GraphItem graphItem)
    {
        foreach (var node in graphItem.NodeData)
        {
            BaseNode tempNode = null;
            if (node.nodeType == nameof(DialogueNode))
            {
                tempNode = graphView.CreateNode <DialogueNode>("Dialogue", Vector2.zero);
            }
            if (tempNode == null)
            {
                continue;
            }

            tempNode.nodeGuid = node.nodeGuid;
            tempNode.SetPosition(new Rect(node.position, graphView.DefaultNodeSize));
            graphView.AddElement(tempNode);
            tempNode.PopulateAdditionalData(node.additionalDataJSON);
        }
    }