Exemplo n.º 1
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 AINode aiNode:

            Debug.Log("AINode Created");
            _graphView.CreateNode("s", localMousePosition);
            return(true);

        default:
            return(false);
        }

        //instead null check and just call the function with userdata as a argument
        //CreateNode(SearchTreeEntry.userData)
    }
Exemplo n.º 2
0
    private void GenerateToolbar()
    {
        var toolbar = new Toolbar();

        var stateBehaviour = new ObjectField("State: ");

        stateBehaviour.objectType = typeof(ActorState);
        stateBehaviour.SetValueWithoutNotify(_curState);
        stateBehaviour.MarkDirtyRepaint();
        stateBehaviour.RegisterValueChangedCallback(evt => _curState = evt.newValue as ActorState);
        toolbar.Add(stateBehaviour);

        var nodeCreateButton = new Button(() => { _graphView.CreateNode("New AI State"); });

        nodeCreateButton.text = "Create State";
        toolbar.Add(nodeCreateButton);
        toolbar.Add(new Button(() => SaveOperation())
        {
            text = "Save"
        });
        rootVisualElement.Add(toolbar);
    }