Ejemplo n.º 1
0
        private void CompleteContextualConnection(IUnitPort source, IUnitPort destination)
        {
            source.ValidlyConnectTo(destination);
            Cache();
            var unitPosition = this.Widget <IUnitWidget>(destination.unit).position.position;
            var portPosition = this.Widget <IUnitPortWidget>(destination).handlePosition.center.PixelPerfect();
            var offset       = portPosition - unitPosition;

            destination.unit.position -= offset;
            this.Widget(destination.unit).Reposition();
            connectionSource = null;
            GUI.changed      = true;
        }
 private void FinishConnection(IUnitPort source, IUnitPort destination)
 {
     if (source.CanValidlyConnectTo(destination))
     {
         UndoUtility.RecordEditedObject("Connect Nodes");
         source.ValidlyConnectTo(destination);
         canvas.connectionSource = null;
         canvas.Widget(source.unit).Reposition();
         canvas.Widget(destination.unit).Reposition();
         GUI.changed = true;
     }
     else
     {
         Debug.LogWarningFormat
         (
             "Cannot connect this {0} to this {1}.\n",
             source.GetType().HumanName().ToLower(),
             destination.GetType().HumanName().ToLower()
         );
     }
 }