Exemplo n.º 1
0
        /// <summary>
        /// 添加连线
        /// </summary>
        /// <param name="linkId">连线GUID</param>
        /// <param name="nextNode">连接到的节点</param>
        public void AddLink(int linkId, GKToyNode nextNode, int height, string parmKey = "")
        {
            bool    vertical = false;
            Vector2 src      = new Vector2(outputRect.x + outputRect.width, outputRect.y + outputRect.height * 0.5f);
            Vector2 dest     = Vector2.zero;

            // 参数链接.
            if (!string.IsNullOrEmpty(parmKey) && nextNode.parmRect.ContainsKey(parmKey))
            {
                dest = new Vector2(nextNode.parmRect[parmKey].rect.x, nextNode.parmRect[parmKey].rect.y + nextNode.parmRect[parmKey].rect.height * 0.5f);
            }
            // 节点链接.
            else
            {
                dest = new Vector2(nextNode.inputRect.x, nextNode.inputRect.y + nextNode.inputRect.height * 0.5f);
            }
            if (10 <= (int)nextNode.nodeType)
            {
                otherLinks.Add(new Link(linkId, GK.ClacLinePoint(src, dest, out vertical, height), vertical, id, nextNode.id, parmKey));
            }
            else
            {
                links.Add(new Link(linkId, GK.ClacLinePoint(src, dest, out vertical, height), vertical, id, nextNode.id, parmKey));
            }

            LinkUpdate();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新单根连线
        /// </summary>
        /// <param name="linkId">要更新连线的Id</param>
        public void UpdateLink(Link link, GKToyNode nextNode, int height)
        {
            bool    vertical = false;
            Vector2 src      = new Vector2(outputRect.x + outputRect.width, outputRect.y + outputRect.height * 0.5f);
            Vector2 dest     = Vector2.zero;

            // 参数链接.
            if (!string.IsNullOrEmpty(link.parmKey) && nextNode.parmRect.ContainsKey(link.parmKey))
            {
                dest = new Vector2(nextNode.parmRect[link.parmKey].rect.x, nextNode.parmRect[link.parmKey].rect.y + nextNode.parmRect[link.parmKey].rect.height * 0.5f);
            }
            // 节点链接.
            else
            {
                dest = new Vector2(nextNode.inputRect.x, nextNode.inputRect.y + nextNode.inputRect.height * 0.5f);
            }
            link.points          = new List <Vector2>(GK.ClacLinePoint(src, dest, out vertical, height));
            link.isFirstVertical = vertical;
        }