public void OnEndDrag(PointerEventData eventData) { ConnectionPoint target = FindConnectionPoint(); if (target == null) { anchor.currentWireBuilder = null; Destroy(this.gameObject); return; } bool valid = true; if (target.connectionType == anchor.connectionType) { valid = false; } if (valid) { Debug.Log("Good connection"); var source = anchor.connectionType == ConnectionPoint.ConnectionType.Output ? anchor : target; var dest = target.connectionType == ConnectionPoint.ConnectionType.Input ? target : anchor; Debug.Assert(source != dest); CircuitDisplay cd = GetComponentInParent <CircuitDisplay>(); if (cd.CanMakeConnection(source, dest)) { cd.MakeConnection(source, dest); } else { Debug.Log("CircuitDisplay says connection illegal"); } } else { Debug.Log("Cancelling, invalid connection"); } anchor.currentWireBuilder = null; Destroy(this.gameObject); }
public void TransferToParent(Transform targetContainer) { //Debug.Log("Transferring to parent: " + targetContainer.name); // Will need to detach wires here, too. // If the target is a circuitDisplay (usually is, except the toolbox), // place ourselves specifically into the gate container. CircuitDisplay cd = targetContainer.GetComponentInParent <CircuitDisplay>(); if (cd != null) { targetContainer = cd.gateContainer.transform; } transform.SetParent(targetContainer, true); transform.localScale = Vector3.one; parentRectTransform = targetContainer.GetComponent <RectTransform>(); }