Exemplo n.º 1
0
        /// <summary>
        /// Creates the label for a single tick.
        /// </summary>
        /// <param name="tick">the tick data.</param>
        protected void CreateSingleLabel(AxisTick tick)
        {
            var label = Instantiate(_tickLabelPrefab, _labelCanvas.transform, false);

            label.text = tick.Label;
            var rectTrans = label.GetComponent <RectTransform>();

            if (_axisPresenter.LabelOrientation == LabelOrientation.Parallel)
            {
                rectTrans.pivot = new Vector2(0.5f, _swapped ? 0.0f : 1.0f);
                label.alignment = TextAnchor.MiddleCenter;
            }
            else
            {
                rectTrans.pivot = new Vector2(_swapped ? 1.0f : 0.0f, 0.5f);
                label.alignment = _swapped ? TextAnchor.MiddleRight : TextAnchor.MiddleLeft;
            }

            float posX = tick.Position * _length;

            if (_mirrored)
            {
                posX = _length - posX;
            }
            float posY = (_tickLength + _labelOffset);

            if (!_swapped)
            {
                posY *= -1;
            }
            rectTrans.localPosition = new Vector3(posX * _invCanvasScale.x, posY * _invCanvasScale.y, 0.0f);
            rectTrans.localRotation = Quaternion.Euler(0, 0, -45 * (int)_axisPresenter.LabelOrientation);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a single tick line for the axis.
        /// </summary>
        /// <param name="iMesh">The intermediate mesh holding the components for the final mesh.</param>
        /// <param name="tick">The tick data.</param>
        protected void CreateSingleTick(IntermediateMesh iMesh, AxisTick tick)
        {
            float posX = tick.Position * _length;

            if (_mirrored)
            {
                posX = _length - posX;
            }
            float posY = _tickLength;

            if (!_swapped)
            {
                posY *= -1;
            }

            iMesh.Vertices.Add(new Vector3(posX, 0, 0));
            iMesh.Vertices.Add(new Vector3(posX, posY, 0));
            iMesh.Normals.Add(-Vector3.forward);
            iMesh.Normals.Add(-Vector3.forward);
            iMesh.Colors.Add(Color.white);
            iMesh.Colors.Add(Color.white);
            iMesh.Indices.Add(iMesh.Vertices.Count - 2);
            iMesh.Indices.Add(iMesh.Vertices.Count - 1);
        }