Exemplo n.º 1
0
 public override void InitializeEdge()
 {
     foreach (var port in outputPorts)
     {
         if (port.orientation == Orientation.Vertical && !port.enabledSelf)
         {
             TransitionView transition = port.GetValue() as TransitionView;
             if (transition != null)
             {
                 EdgeView edge = new EdgeView(transition.input, port);
                 owner.Connect(edge, false);
                 edge.SetEnabled(false);
             }
         }
     }
 }
Exemplo n.º 2
0
        public override void SetPosition(Rect newPos)
        {
            // if(newPos != targetNode.editorRect && uNodePreference.GetPreference().snapNode) {
            //  var preference = uNodePreference.GetPreference();
            //  float range = preference.snapRange;
            //  newPos.x = NodeEditorUtility.SnapTo(newPos.x, range);
            //  newPos.y = NodeEditorUtility.SnapTo(newPos.y, range);
            //  if(preference.snapToPin && owner.selection.Count == 1) {
            //      var connectedPort = inputPorts.Where((p) => p.connected).ToList();
            //      for(int i = 0; i < connectedPort.Count; i++) {
            //          if(connectedPort[i].orientation != Orientation.Vertical) continue;
            //          var edges = connectedPort[i].GetEdges();
            //          foreach(var e in edges) {
            //              if(e != null) {
            //                  float distanceToPort = e.edgeControl.to.x - e.edgeControl.from.x;
            //                  if(Mathf.Abs(distanceToPort) <= preference.snapToPinRange && Mathf.Abs(newPos.x - layout.x) <= preference.snapToPinRange) {
            //                      newPos.x = layout.x - distanceToPort;
            //                      break;
            //                  }
            //              }
            //          }
            //      }
            //  }
            // }
            float xPos = newPos.x - targetNode.editorRect.x;
            float yPos = newPos.y - targetNode.editorRect.y;

            Teleport(newPos);

            if (xPos != 0 || yPos != 0)
            {
                foreach (var port in outputPorts)
                {
                    if (port.orientation == Orientation.Vertical && !port.enabledSelf)
                    {
                        TransitionView transition = port.GetValue() as TransitionView;
                        if (transition != null)
                        {
                            Rect rect = transition.transition.editorPosition;
                            rect.x += targetNode.editorRect.x;
                            rect.y += targetNode.editorRect.y;
                            transition.Teleport(rect);
                        }
                    }
                }
            }
        }