Example #1
0
                #pragma warning restore 0612
#endif

        /// <summary>
        /// Modifies the mesh.
        /// </summary>
        public override void ModifyMesh(VertexHelper vh)
        {
            if (!isActiveAndEnabled)
            {
                return;
            }

            bool  isText          = isTMPro || graphic is Text;
            float normalizedIndex = ptex.GetNormalizedIndex(this);

            // rect.
            Rect rect = m_EffectArea.GetEffectArea(vh, rectTransform.rect);

            // rotation.
            float   rad = m_Rotation * Mathf.Deg2Rad;
            Vector2 dir = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad));

            dir.x *= rect.height / rect.width;
            dir    = dir.normalized;

            // Calculate vertex position.
            UIVertex  vertex = default(UIVertex);
            Vector2   nomalizedPos;
            Matrix2x3 localMatrix = new Matrix2x3(rect, dir.x, dir.y);                  // Get local matrix.

            for (int i = 0; i < vh.currentVertCount; i++)
            {
                vh.PopulateUIVertex(ref vertex, i);
                m_EffectArea.GetNormalizedFactor(i, localMatrix, vertex.position, isText, out nomalizedPos);

                if (isTMPro)
                {
                    vertex.uv2 = new Vector2(
                        Packer.ToFloat(nomalizedPos.y, normalizedIndex), 0
                        );
                }
                else
                {
                    vertex.uv0 = new Vector2(
                        Packer.ToFloat(vertex.uv0.x, vertex.uv0.y),
                        Packer.ToFloat(nomalizedPos.y, normalizedIndex)
                        );
                }

                vh.SetUIVertex(vertex, i);
            }
        }