예제 #1
0
        /// <summary>
        /// 自动连接
        /// </summary>
        /// <returns></returns>
        private IEnumerator AutoLinkItems()
        {
            var links = SurchLinkItems();

            for (int i = 0; i < defultLink.Count; i++)
            {
                var linkGroup = defultLink[i];

                var itemA = links[linkGroup.ItemA];
                var itemB = links[linkGroup.ItemB];

                var portA = itemA.ChildNodes[linkGroup.portA];
                var portB = itemB.ChildNodes[linkGroup.portB];

                if (portA.ConnectedNode != null || portB.ConnectedNode != null)
                {
                    continue;
                }
                if (itemB.PickUpAble)
                {
                    yield return(MoveBToA(portA, portB));
                }
                else if (itemA.PickUpAble)
                {
                    yield return(MoveBToA(portB, portA));
                }
                else
                {
                    Debug.LogErrorFormat("{0} and {1} can`t Move Both!", itemA, itemB);
                }
                //anglePos = portA.transform;
                LinkUtil.AttachNodes(portB, portA);
            }
            TryComplete();
        }
예제 #2
0
        /// <summary>
        /// 快速连接元素
        /// </summary>
        private void QuickLinkItems()
        {
            Debug.Log("QuickLinkItems");
            var links = SurchLinkItems();

            for (int i = 0; i < defultLink.Count; i++)
            {
                var linkGroup = defultLink[i];

                var itemA = links[linkGroup.ItemA];
                var itemB = links[linkGroup.ItemB];

                var portA = itemA.ChildNodes[linkGroup.portA];
                var portB = itemB.ChildNodes[linkGroup.portB];

                if (portA.ConnectedNode != null || portB.ConnectedNode != null)
                {
                    continue;
                }

                //anglePos = portA.transform;
                LinkUtil.AttachNodes(portB, portA);
                portB.ResetTransform();
            }
        }
        public void TryConnect()
        {
            if (activeNode != null && targetNode != null)
            {
                LinkUtil.AttachNodes(activeNode, targetNode);

                if (onConnected != null)
                {
                    onConnected.Invoke(new LinkPort[] { activeNode, targetNode });
                }

                activeNode = null;
                targetNode = null;
            }
        }