コード例 #1
0
        void TrackGraphElement(Port port)
        {
            if (port.panel != null) // if the panel is null therefore the port is not yet attached to its hierarchy, so postpone the register
            {
                DoTrackGraphElement(port);
            }

            port.RegisterCallback <AttachToPanelEvent>(OnPortAttach);
            port.RegisterCallback <DetachFromPanelEvent>(OnPortDetach);
        }
コード例 #2
0
        void DoTrackGraphElement(Port port)
        {
            port.RegisterCallback <GeometryChangedEvent>(OnPortGeometryChanged);

            VisualElement current = port.hierarchy.parent;

            while (current != null)
            {
                if (current is GraphView.Layer)
                {
                    break;
                }
                if (current != port.node) // if we encounter our node ignore it but continue in the case there are nodes inside nodes
                {
                    current.RegisterCallback <GeometryChangedEvent>(OnGeometryChanged);
                }

                current = current.hierarchy.parent;
            }
            if (port.node != null)
            {
                port.node.RegisterCallback <GeometryChangedEvent>(OnGeometryChanged);
            }
        }