private void Awake() { if (group != null) { foreach (NodePort port in group.ports) { GameObject portGO = Instantiate(port.direction == NodePort.IO.Input ? graph.inputPort : graph.outputPort, body.transform); portGO.transform.Find("Label").GetComponent <Text>().text = port.fieldName.NicifyString(); UGUIPort guiport = portGO.GetComponentInChildren <UGUIPort>(); guiport.fieldName = port.fieldName; guiport.node = port.node; guiport.name = port.fieldName; if (port.IsConnected && port.Connection == null) { Debug.Log("Lost some connection" + " ___ " + port.fieldName); } ports.Add(guiport); if (port.IsDynamic) { Debug.LogWarning("Instantiate dynamic port!"); } } transform.Find("Header/Title").GetComponent <TextMeshProUGUI>().text = group.name; } else { gameObject.SetActive(false); } }
public void OnBeginDrag(PointerEventData eventData) { if (port.IsOutput) { tempConnection = Instantiate(graph.runtimeConnectionPrefab); tempConnection.transform.SetParent(graph.scrollRect.content); tempConnection.SetPosition(transform.position, eventData.position); startPos = transform.position; startPort = port; } else { if (port.IsConnected) { NodePort output = port.Connection; IUGUINode otherNode = graph.GetRuntimeNode(output.node); UGUIPort otherUGUIPort = otherNode.GetPort(output.fieldName, output.node); output.Disconnect(port); tempConnection = Instantiate(graph.runtimeConnectionPrefab); tempConnection.transform.SetParent(graph.scrollRect.content); tempConnection.SetPosition(otherUGUIPort.transform.position, eventData.position); startPos = otherUGUIPort.transform.position; startPort = otherUGUIPort.port; graph.GetRuntimeNode(node).UpdateGUI(); } } }
private void SetDefaultPortData(GameObject portGO, NodePort port) { UGUIPort guiport = portGO.GetComponentInChildren <UGUIPort>(); guiport.fieldName = port.fieldName; guiport.node = node; guiport.name = port.fieldName; ports.Add(guiport); }
public void OnDrag(PointerEventData eventData) { if (tempConnection == null) { return; } UGUIPort otherPort = FindPortInStack(eventData.hovered); tempHovered = otherPort; tempConnection.SetPosition(startPos, eventData.position); }
public UGUIPort FindPortInStack(List <GameObject> stack) { for (int i = 0; i < stack.Count; i++) { UGUIPort port = stack[i].GetComponent <UGUIPort>(); if (port) { return(port); } } return(null); }