public void SetEntityB(BlueprintEntity b, BlueprintEntityPin anchorB) { this.b = b; this.anchorB = anchorB; _anchorBTransform = anchorB.transform; _rectB = anchorB.GetComponent <RectTransform>(); _rectParentB = _anchorBTransform.parent.GetComponent <RectTransform>(); }
public void SetEntityA(BlueprintEntity a, BlueprintEntityPin anchorA) { this.a = a; this.anchorA = anchorA; _anchorATransform = anchorA.transform; _rectA = anchorA.GetComponent <RectTransform>(); _rectParentA = _anchorATransform.parent.GetComponent <RectTransform>(); }
public bool DropToConnector(BlueprintEntityPin oppositionPin) { var connector = BlueprintConnector.current; // if having a same pin type at two head, remove them. if (pinType == BlueprintEntityPinType.In) { if (connector.b != null) { Destroy(connector.gameObject); BlueprintConnector.current = null; return(false); } connector.SetEntityB(entity, this); } else { if (connector.a != null) { Destroy(connector.gameObject); BlueprintConnector.current = null; return(false); } connector.SetEntityA(entity, this); } // create block connector var blockConnector = connector.CreateBlockConnector(); if (dropToConnectorCallback != null) { dropToConnectorCallback.Invoke(blockConnector); } if (oppositionPin.dropToConnectorCallback != null) { oppositionPin.dropToConnectorCallback.Invoke(blockConnector); } Debug.Log(blockConnector.a); Debug.Log(blockConnector.b); oppositionPin.blueprintConnector = blueprintConnector = connector; BlueprintConnector.current = null; return(true); }
public void OnEndDrag(PointerEventData eventData) { // detect an appropriate pin as oppose one BlueprintEntityPin detectedPin = null; foreach (var go in eventData.hovered) { if (go.Equals(null)) { continue; } var pin = go.GetComponent <BlueprintEntityPin>(); if (pin == null || pin.Equals(null)) { continue; } if (pin.GetInstanceID() == GetInstanceID()) { continue; } detectedPin = pin; break; } // if detected pin has been found if (detectedPin != null && !detectedPin.Equals(null)) { BlueprintConnector.current.OnPinDragEnd(this); detectedPin.DropToConnector(this); } else { var currentConnector = BlueprintConnector.current; if (currentConnector != null && !currentConnector.Equals(null)) { Destroy(currentConnector.gameObject); } } }
public void OnPinDragEnd(BlueprintEntityPin pin) { Destroy(_connectorOverlay.gameObject); _connectorOverlay = null; }
public void OnPinDrag(BlueprintEntityPin pin) { DrawEndLineByMouse(pin.pinType); }