Ejemplo n.º 1
0
    public void Update()
    {
        Mesh mesh = textMesh.mesh;

        Vector3[]    vertices = mesh.vertices;
        TMP_TextInfo textInfo = textMesh.textInfo;
        float        time     = Time.unscaledTime;

        float     charsCount = endIndex - startIndex;
        float     cos        = Mathf.Cos(time * ONE_SECOND_FREQUENCY * frequency);
        float     angle      = cos * amplitude;
        Matrix4x4 matrix     = Matrix4x4.Rotate(Quaternion.Euler(0, 0, angle));

        for (int i = 0; i < charsCount; i++)
        {
            int characterIndex         = i + startIndex;
            TMP_CharacterInfo charInfo = textInfo.characterInfo[characterIndex];

            if (!charInfo.isVisible)
            {
                continue;
            }
            int vertexIndex = charInfo.vertexIndex;
            TMProHelpers.ApplyMatrixToChar(vertices, vertexIndex, matrix);
        }

        mesh.vertices = vertices;
        textMesh.canvasRenderer.SetMesh(mesh);
    }
Ejemplo n.º 2
0
    public void AnimationUpdate()
    {
        Mesh mesh = textMesh.mesh;

        Vector3[] vertices  = mesh.vertices;
        float     duration  = frequency * length;
        Vector3   minVector = Vector3.one;
        Vector3   maxVector = new Vector3(amplitude, amplitude, 1);

        for (int i = sizeCharEffects.Count - 1; i >= 0; i--)
        {
            int       vertexIndex    = sizeCharEffects[i].vertexIndex;
            float     timeDiff       = sizeCharEffects[i].GetTimeDiff(effectTimeElapsed);
            float     normalizedTime = timeDiff / duration;
            Matrix4x4 matrix         = Matrix4x4.Scale(Vector3.Lerp(maxVector, minVector, normalizedTime));

            TMProHelpers.ApplyMatrixToChar(vertices, vertexIndex, matrix);

            if (normalizedTime >= 1)
            {
                sizeCharEffects.RemoveAt(i);
            }
        }

        mesh.vertices = vertices;
        textMesh.canvasRenderer.SetMesh(mesh);

        if (sizeCharEffects.Count == 0 && charactersShown >= charslength)
        {
            isEffectFinished = true;
        }
    }