Пример #1
0
    private void OnGUI()
    {
        DrawGrid(20, 0.2f, Color.gray);
        DrawGrid(100, 0.4f, Color.gray);

        ProcessEvents(Event.current);

        if (GraphToEdit == null)
        {
            Reset();
            return;
        }

        if (GraphToEdit != null)
        {
            if (RegisteredFunctionDictionary == null)
            {
                Reset();
            }
        }

        RenderGraph();
        // draw editors for selected node

        if (GraphToEdit != null && GraphToEdit.IsPinSelected())
        {
            EditorNode OwnerNode = GraphToEdit.GetSelectedNode();
            Vector2    PinPos    = OwnerNode.GetPinRect(GraphToEdit.GetSelectedElementID().PinID).center;
            EditorGraphDrawUtils.Line(PinPos, Event.current.mousePosition, Color.magenta);
        }
    }
Пример #2
0
    public void RenderLink(EditorGraph Graph)
    {
        EditorNode FromNode = Graph.GetNodeFromID(NodeID_From);
        EditorNode ToNode   = Graph.GetNodeFromID(NodeID_To);

        if (FromNode == null || ToNode == null)
        {
            return;
        }

        Rect FromRect = FromNode.GetPinRect(PinID_From);
        Rect ToRect   = ToNode.GetPinRect(PinID_To);

        EditorGraphDrawUtils.Line(FromRect.center, ToRect.center, Color.black);
    }
Пример #3
0
    public void RenderNode(EditorGraph Graph, bool bIsSelected)
    {
        const float selectionBorder = 5.0f;

        if (bIsSelected)
        {
            EditorGraphDrawUtils.DrawRect(_renderData.NodeRect.min - Vector2.one * selectionBorder, _renderData.NodeRect.max + Vector2.one * selectionBorder, Color.yellow);
        }
        GUI.Box(_renderData.NodeRect, " ");

        for (int PinIndex = 0; PinIndex < PinCount; ++PinIndex)
        {
            Pins[PinIndex].RenderPin(Graph, this);
        }

        RenderNodeText();
    }