diff --git a/com.unity.ugui/Runtime/TMP/TextMeshProUGUI.cs b/com.unity.ugui/Runtime/TMP/TextMeshProUGUI.cs index 79259af..5dae438 100644 --- a/com.unity.ugui/Runtime/TMP/TextMeshProUGUI.cs +++ b/com.unity.ugui/Runtime/TMP/TextMeshProUGUI.cs @@ -5055,7 +5055,7 @@ protected virtual void GenerateTextMesh() underlineMaxScale = underlineStartScale; xScaleMax = xScale; } - underline_start = new Vector3(m_textInfo.characterInfo[i].bottomLeft.x, underlineBaseLine, 0); + underline_start = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i].bottomRight.x : m_textInfo.characterInfo[i].bottomLeft.x, underlineBaseLine, 0); underlineColor = m_textInfo.characterInfo[i].underlineColor; } } @@ -5064,7 +5064,7 @@ protected virtual void GenerateTextMesh() if (beginUnderline && m_characterCount == 1) { beginUnderline = false; - underline_end = new Vector3(m_textInfo.characterInfo[i].topRight.x, underlineBaseLine, 0); + underline_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i].topLeft.x : m_textInfo.characterInfo[i].topRight.x, underlineBaseLine, 0); underlineEndScale = m_textInfo.characterInfo[i].scale; DrawUnderlineMesh(underline_start, underline_end, ref last_vert_index, underlineStartScale, underlineEndScale, underlineMaxScale, xScaleMax, underlineColor); @@ -5078,12 +5078,12 @@ protected virtual void GenerateTextMesh() if (isWhiteSpace || unicode == 0x200B) { int lastVisibleCharacterIndex = lineInfo.lastVisibleCharacterIndex; - underline_end = new Vector3(m_textInfo.characterInfo[lastVisibleCharacterIndex].topRight.x, underlineBaseLine, 0); + underline_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[lastVisibleCharacterIndex].topLeft.x : m_textInfo.characterInfo[lastVisibleCharacterIndex].topRight.x, underlineBaseLine, 0); underlineEndScale = m_textInfo.characterInfo[lastVisibleCharacterIndex].scale; } else { // End underline if last character of the line. - underline_end = new Vector3(m_textInfo.characterInfo[i].topRight.x, underlineBaseLine, 0); + underline_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i].topLeft.x : m_textInfo.characterInfo[i].topRight.x, underlineBaseLine, 0); underlineEndScale = m_textInfo.characterInfo[i].scale; } @@ -5096,7 +5096,7 @@ protected virtual void GenerateTextMesh() else if (beginUnderline && !isUnderlineVisible) { beginUnderline = false; - underline_end = new Vector3(m_textInfo.characterInfo[i - 1].topRight.x, underlineBaseLine, 0); + underline_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i - 1].topLeft.x : m_textInfo.characterInfo[i - 1].topRight.x, underlineBaseLine, 0); underlineEndScale = m_textInfo.characterInfo[i - 1].scale; DrawUnderlineMesh(underline_start, underline_end, ref last_vert_index, underlineStartScale, underlineEndScale, underlineMaxScale, xScaleMax, underlineColor); @@ -5108,7 +5108,7 @@ protected virtual void GenerateTextMesh() { // End underline if underline color has changed. beginUnderline = false; - underline_end = new Vector3(m_textInfo.characterInfo[i].topRight.x, underlineBaseLine, 0); + underline_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i].topLeft.x : m_textInfo.characterInfo[i].topRight.x, underlineBaseLine, 0); underlineEndScale = m_textInfo.characterInfo[i].scale; DrawUnderlineMesh(underline_start, underline_end, ref last_vert_index, underlineStartScale, underlineEndScale, underlineMaxScale, xScaleMax, underlineColor); @@ -5123,7 +5123,7 @@ protected virtual void GenerateTextMesh() if (beginUnderline == true) { beginUnderline = false; - underline_end = new Vector3(m_textInfo.characterInfo[i - 1].topRight.x, underlineBaseLine, 0); + underline_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i - 1].topLeft.x : m_textInfo.characterInfo[i - 1].topRight.x, underlineBaseLine, 0); underlineEndScale = m_textInfo.characterInfo[i - 1].scale; DrawUnderlineMesh(underline_start, underline_end, ref last_vert_index, underlineStartScale, underlineEndScale, underlineMaxScale, xScaleMax, underlineColor); @@ -5158,7 +5158,7 @@ protected virtual void GenerateTextMesh() beginStrikethrough = true; strikethroughPointSize = m_textInfo.characterInfo[i].pointSize; strikethroughScale = m_textInfo.characterInfo[i].scale; - strikethrough_start = new Vector3(m_textInfo.characterInfo[i].bottomLeft.x, m_textInfo.characterInfo[i].baseLine + strikethroughOffset * strikethroughScale, 0); + strikethrough_start = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i].bottomRight.x : m_textInfo.characterInfo[i].bottomLeft.x, m_textInfo.characterInfo[i].baseLine + strikethroughOffset * strikethroughScale, 0); strikethroughColor = m_textInfo.characterInfo[i].strikethroughColor; strikethroughBaseline = m_textInfo.characterInfo[i].baseLine; //Debug.Log("Char [" + currentCharacter + "] Start Strikethrough POS: " + strikethrough_start); @@ -5169,7 +5169,7 @@ protected virtual void GenerateTextMesh() if (beginStrikethrough && m_characterCount == 1) { beginStrikethrough = false; - strikethrough_end = new Vector3(m_textInfo.characterInfo[i].topRight.x, m_textInfo.characterInfo[i].baseLine + strikethroughOffset * strikethroughScale, 0); + strikethrough_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i].topLeft.x : m_textInfo.characterInfo[i].topRight.x, m_textInfo.characterInfo[i].baseLine + strikethroughOffset * strikethroughScale, 0); DrawUnderlineMesh(strikethrough_start, strikethrough_end, ref last_vert_index, strikethroughScale, strikethroughScale, strikethroughScale, xScale, strikethroughColor); } @@ -5179,16 +5179,17 @@ protected virtual void GenerateTextMesh() if (isWhiteSpace || unicode == 0x200B) { int lastVisibleCharacterIndex = lineInfo.lastVisibleCharacterIndex; - strikethrough_end = new Vector3(m_textInfo.characterInfo[lastVisibleCharacterIndex].topRight.x, m_textInfo.characterInfo[lastVisibleCharacterIndex].baseLine + strikethroughOffset * strikethroughScale, 0); + strikethrough_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[lastVisibleCharacterIndex].topLeft.x : m_textInfo.characterInfo[lastVisibleCharacterIndex].topRight.x, m_textInfo.characterInfo[lastVisibleCharacterIndex].baseLine + strikethroughOffset * strikethroughScale, 0); } else { // Terminate Strikethrough at last character of line. - strikethrough_end = new Vector3(m_textInfo.characterInfo[i].topRight.x, m_textInfo.characterInfo[i].baseLine + strikethroughOffset * strikethroughScale, 0); + strikethrough_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i].topLeft.x : m_textInfo.characterInfo[i].topRight.x, m_textInfo.characterInfo[i].baseLine + strikethroughOffset * strikethroughScale, 0); } beginStrikethrough = false; DrawUnderlineMesh(strikethrough_start, strikethrough_end, ref last_vert_index, strikethroughScale, strikethroughScale, strikethroughScale, xScale, strikethroughColor); + } else if (beginStrikethrough && i < m_characterCount && (m_textInfo.characterInfo[i + 1].pointSize != strikethroughPointSize || !TMP_Math.Approximately(m_textInfo.characterInfo[i + 1].baseLine + offset.y, strikethroughBaseline))) { @@ -5197,9 +5198,9 @@ protected virtual void GenerateTextMesh() int lastVisibleCharacterIndex = lineInfo.lastVisibleCharacterIndex; if (i > lastVisibleCharacterIndex) - strikethrough_end = new Vector3(m_textInfo.characterInfo[lastVisibleCharacterIndex].topRight.x, m_textInfo.characterInfo[lastVisibleCharacterIndex].baseLine + strikethroughOffset * strikethroughScale, 0); + strikethrough_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[lastVisibleCharacterIndex].topLeft.x : m_textInfo.characterInfo[i].topRight.x, m_textInfo.characterInfo[lastVisibleCharacterIndex].baseLine + strikethroughOffset * strikethroughScale, 0); else - strikethrough_end = new Vector3(m_textInfo.characterInfo[i].topRight.x, m_textInfo.characterInfo[i].baseLine + strikethroughOffset * strikethroughScale, 0); + strikethrough_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i].topLeft.x : m_textInfo.characterInfo[i].topRight.x, m_textInfo.characterInfo[i].baseLine + strikethroughOffset * strikethroughScale, 0); DrawUnderlineMesh(strikethrough_start, strikethrough_end, ref last_vert_index, strikethroughScale, strikethroughScale, strikethroughScale, xScale, strikethroughColor); //Debug.Log("Char [" + currentCharacter + "] at Index: " + i + " End Strikethrough POS: " + strikethrough_end + " Baseline: " + m_textInfo.characterInfo[i].baseLine.ToString("f3")); @@ -5208,7 +5209,7 @@ protected virtual void GenerateTextMesh() { // Terminate Strikethrough if font asset changes. beginStrikethrough = false; - strikethrough_end = new Vector3(m_textInfo.characterInfo[i].topRight.x, m_textInfo.characterInfo[i].baseLine + strikethroughOffset * strikethroughScale, 0); + strikethrough_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i].topLeft.x : m_textInfo.characterInfo[i].topRight.x, m_textInfo.characterInfo[i].baseLine + strikethroughOffset * strikethroughScale, 0); DrawUnderlineMesh(strikethrough_start, strikethrough_end, ref last_vert_index, strikethroughScale, strikethroughScale, strikethroughScale, xScale, strikethroughColor); } @@ -5216,10 +5217,11 @@ protected virtual void GenerateTextMesh() { // Terminate Strikethrough if character is not visible. beginStrikethrough = false; - strikethrough_end = new Vector3(m_textInfo.characterInfo[i - 1].topRight.x, m_textInfo.characterInfo[i - 1].baseLine + strikethroughOffset * strikethroughScale, 0); + strikethrough_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i - 1].topLeft.x : m_textInfo.characterInfo[i - 1].topRight.x, m_textInfo.characterInfo[i - 1].baseLine + strikethroughOffset * strikethroughScale, 0); DrawUnderlineMesh(strikethrough_start, strikethrough_end, ref last_vert_index, strikethroughScale, strikethroughScale, strikethroughScale, xScale, strikethroughColor); } + } else { @@ -5227,7 +5229,7 @@ protected virtual void GenerateTextMesh() if (beginStrikethrough == true) { beginStrikethrough = false; - strikethrough_end = new Vector3(m_textInfo.characterInfo[i - 1].topRight.x, m_textInfo.characterInfo[i - 1].baseLine + strikethroughOffset * strikethroughScale, 0); + strikethrough_end = new Vector3(isRightToLeftText ? m_textInfo.characterInfo[i - 1].topLeft.x : m_textInfo.characterInfo[i - 1].topRight.x, m_textInfo.characterInfo[i - 1].baseLine + strikethroughOffset * strikethroughScale, 0); DrawUnderlineMesh(strikethrough_start, strikethrough_end, ref last_vert_index, strikethroughScale, strikethroughScale, strikethroughScale, xScale, strikethroughColor); }