예제 #1
0
        public void DeleteConnectionLine(ConnectionLineView connectionLineView)
        {
            if (connectionLineView == null)
            {
                return;
            }

            if (!connectionLineList.Contains(connectionLineView))
            {
                return;
            }

            PortEditorView flowOutPort = connectionLineView.FlowOutPortView;
            PortEditorView flowInport  = connectionLineView.FlowInPortView;

            if (flowOutPort.connectedPortList.Contains(flowInport))
            {
                flowOutPort.connectedPortList.Remove(flowInport);
            }

            if (flowInport.connectedPortList.Contains(flowOutPort))
            {
                flowInport.connectedPortList.Remove(flowOutPort);
            }

            connectionLineList.Remove(connectionLineView);

            if (CurrentConnectionLineList.Contains(connectionLineView))
            {
                CurrentConnectionLineList.Remove(connectionLineView);
            }
        }
예제 #2
0
        public void FindConnectionByPortsAndRemoveIt(PortEditorView portA, PortEditorView portB)
        {
            if (portA == null || portB == null)
            {
                return;
            }

            if (portA.FlowType == portB.FlowType)
            {
                Debug.LogError("RemoveConnectionByPort err: 两个接口类型相同");
                return;
            }

            PortEditorView flowInPort  = portA.FlowType == FlowType.In ? portA : portB;
            PortEditorView flowOutPort = portA.FlowType == FlowType.Out ? portA : portB;

            ConnectionLineView needRemoveConnectionLineView = null;

            for (int i = 0; i < connectionLineList.Count; i++)
            {
                ConnectionLineView connectionLineView = connectionLineList[i];
                if (connectionLineView.FlowInPortView == flowInPort && connectionLineView.FlowOutPortView == flowOutPort)
                {
                    needRemoveConnectionLineView = connectionLineView;
                    break;
                }
            }

            if (needRemoveConnectionLineView != null)
            {
                connectionLineList.Remove(needRemoveConnectionLineView);
                if (CurrentConnectionLineList.Contains(needRemoveConnectionLineView))
                {
                    CurrentConnectionLineList.Remove(needRemoveConnectionLineView);
                }
            }
        }