Ejemplo n.º 1
0
        private void UpdatePortInput(LogicPort port)
        {
            var inputView = _portInputContainer.OfType <PortInputView>()
                            .First(x => Equals(x.Description, port.Description));

            var currentRect = new Rect(inputView.style.positionLeft, inputView.style.positionTop, inputView.style.width,
                                       inputView.style.height);
            var targetRect = new Rect(0.0f, 0.0f, port.layout.width, port.layout.height);

            targetRect = port.ChangeCoordinatesTo(inputView.shadow.parent, targetRect);
            var centerY = targetRect.center.y;
            var centerX = targetRect.xMax - currentRect.width;

            currentRect.center = new Vector2(centerX, centerY);

            inputView.style.positionTop = currentRect.yMin;
            var newHeight = inputView.parent.layout.height;

            foreach (var element in inputView.parent.Children())
            {
                newHeight = Mathf.Max(newHeight, element.style.positionTop + element.layout.height);
            }
            if (Math.Abs(inputView.parent.style.height - newHeight) > 1e-3)
            {
                inputView.parent.style.height = newHeight;
            }
        }
Ejemplo n.º 2
0
 public void RemoveEdgesConnectedTo(LogicPort logicPort)
 {
     _foundEdges.Clear();
     _logicGraphEditorObject.LogicGraphData.GetEdges(logicPort.Slot.Owner.NodeGuid, logicPort.Slot.MemberName, _foundEdges);
     for (int i = 0; i < _foundEdges.Count; ++i)
     {
         RemoveEdge(_foundEdges[i]);
     }
 }
Ejemplo n.º 3
0
        public bool AddEdge(SerializedEdge serializedEdge)
        {
            LogicNodeView sourceNodeView = _graphView.nodes.ToList().OfType <LogicNodeView>()
                                           .FirstOrDefault(x => x.LogicNodeEditor.NodeGuid == serializedEdge.SourceNodeGuid);

            if (sourceNodeView == null)
            {
                Debug.LogWarning($"Source NodeGUID not found {serializedEdge.SourceNodeGuid}");
                return(false);
            }

            LogicPort sourceAnchor = sourceNodeView.outputContainer.Children().OfType <LogicPort>()
                                     .FirstOrDefault(x => x.Slot.MemberName == serializedEdge.SourceMemberName);

            if (sourceAnchor == null)
            {
                Debug.LogError($"Source anchor null {serializedEdge.SourceMemberName} {serializedEdge.SourceNodeGuid}");
                return(false);
            }

            LogicNodeView targetNodeView = _graphView.nodes.ToList().OfType <LogicNodeView>()
                                           .FirstOrDefault(x => x.LogicNodeEditor.NodeGuid == serializedEdge.TargetNodeGuid);

            if (targetNodeView == null)
            {
                Debug.LogWarning($"Target NodeGUID not found {serializedEdge.TargetNodeGuid}");
                return(false);
            }

            LogicPort targetAnchor = targetNodeView.inputContainer.Children().OfType <LogicPort>()
                                     .FirstOrDefault(x => x.Slot.MemberName == serializedEdge.TargetMemberName);

            if (targetAnchor == null)
            {
                Debug.LogError($"Target anchor null {serializedEdge.SourceMemberName} {serializedEdge.TargetNodeGuid}");
                return(false);
            }

            var edgeView = new Edge
            {
                userData = serializedEdge,
                output   = sourceAnchor,
                input    = targetAnchor
            };

            edgeView.output.Connect(edgeView);
            edgeView.input.Connect(edgeView);
            _graphView.AddElement(edgeView);
            targetNodeView.UpdatePortInputVisibilities();
            sourceNodeView.UpdatePortInputVisibilities();

            return(true);
        }
Ejemplo n.º 4
0
        public static Port Create(LogicSlot logicSlot, IEdgeConnectorListener connectorListener)
        {
            var port = new LogicPort(Orientation.Horizontal,
                                     logicSlot.isInputSlot ? Direction.Input : Direction.Output,
                                     logicSlot.isInputSlot ? Capacity.Single : Capacity.Multi,
                                     null)
            {
                m_EdgeConnector = new EdgeConnector <Edge>(connectorListener),
            };

            port.AddManipulator(port.m_EdgeConnector);
            port.Slot = logicSlot;
            return(port);
        }
Ejemplo n.º 5
0
 private void AddPorts(IEnumerable <LogicSlot> slots)
 {
     foreach (var slot in slots)
     {
         var port = LogicPort.Create(slot, _connectorListener);
         if (slot.isOutputSlot)
         {
             outputContainer.Add(port);
         }
         else
         {
             inputContainer.Add(port);
         }
     }
 }
Ejemplo n.º 6
0
 void SetPortInputPosition(LogicPort port, PortInputView inputView)
 {
     inputView.style.top           = port.layout.y;
     inputView.parent.style.height = inputContainer.layout.height;
 }