Ejemplo n.º 1
0
        /// <summary>
        /// Adds the line.
        /// </summary>
        /// <param name="source">Source.</param>
        /// <param name="line">Line.</param>
        /// <param name="vbo">Vbo.</param>
        public void AddLine(RectTransform source, ConnectorLine line, List <UIVertex> vbo)
        {
            if ((line == null) || (line.Target == null) || (!line.Target.gameObject.activeInHierarchy))
            {
                return;
            }
            var start_point = GetPoint(source, line.Start);
            var end_point   = GetPoint(line.Target, line.End);

            SetPoints(start_point, end_point, line.Thickness, vbo);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the line.
        /// </summary>
        /// <returns>The line.</returns>
        /// <param name="source">Source.</param>
        /// <param name="line">Line.</param>
        /// <param name="vh">Vertex helper.</param>
        /// <param name="index">Index.</param>
        public int AddLine(RectTransform source, ConnectorLine line, VertexHelper vh, int index)
        {
            if ((line == null) || (line.Target == null) || (!line.Target.gameObject.activeInHierarchy))
            {
                return(0);
            }

            var start_point = GetPoint(source, line.Start);
            var end_point   = GetPoint(line.Target, line.End);

            return(SetPoints(start_point, end_point, line.Thickness, vh, index));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Display node.
        /// </summary>
        /// <param name="node">Node.</param>
        /// <param name="connector">Connector.</param>
        /// <param name="position">Position.</param>
        /// <returns>Node size.</returns>
        protected virtual Vector2 DisplayNode(TreeNode <TItem> node, MultipleConnector connector, Vector2 position)
        {
            var component = GetComponentInstance();

            var size = GetNodeSize(node);

            (component.transform as RectTransform).anchoredPosition = IsHorizontal()
                                ? new Vector2(position.x, -position.y - (size.y / 2f))
                                : new Vector2(position.x + (size.x / 2f), -position.y);

            component.SetData(node);

            if (connector != null)
            {
                var start = ConnectorPosition.Center;
                var end   = ConnectorPosition.Center;

                switch (Direction)
                {
                case TreeGraphDirections.TopToBottom:
                    start = ConnectorPosition.Bottom;
                    end   = ConnectorPosition.Top;
                    break;

                case TreeGraphDirections.BottomToTop:
                    start = ConnectorPosition.Top;
                    end   = ConnectorPosition.Bottom;
                    break;

                case TreeGraphDirections.LeftToRight:
                    start = ConnectorPosition.Right;
                    end   = ConnectorPosition.Left;
                    break;

                case TreeGraphDirections.RightToLeft:
                    start = ConnectorPosition.Left;
                    end   = ConnectorPosition.Right;
                    break;

                default:
#if NETFX_CORE
                    throw new ArgumentException("Unsupported direction: " + Direction);
#else
                    throw new InvalidEnumArgumentException("Unsupported direction: " + Direction);
#endif
                }

                var line = new ConnectorLine()
                {
                    Target    = component.transform as RectTransform,
                    Start     = start,
                    End       = end,
                    Thickness = 1f,
                    Type      = ConnectorType.Straight,
                };
                connector.Lines.Add(line);
            }

            if (node.IsExpanded)
            {
                var new_position = GetNextLevelPosition(position);
                DisplayNodes(node.Nodes, component.GetComponent <MultipleConnector>(), new_position);
            }

            return(size);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Init this instance.
        /// </summary>
        protected override void Init()
        {
            base.Init();

            Line = line;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        protected override void Start()
        {
            base.Start();

            Line = line;
        }