TMP: Fix caret height not correct with empty content.
This commit is contained in:
@@ -4524,7 +4524,12 @@ namespace TMPro
|
|||||||
if (m_TextViewport != null)
|
if (m_TextViewport != null)
|
||||||
horizontalPadding += m_TextViewport.offsetMin.x - m_TextViewport.offsetMax.x;
|
horizontalPadding += m_TextViewport.offsetMin.x - m_TextViewport.offsetMax.x;
|
||||||
|
|
||||||
return m_TextComponent.preferredWidth + horizontalPadding; // Should add some extra padding for caret
|
var preferredWidth = m_TextComponent.preferredWidth;
|
||||||
|
|
||||||
|
if (m_Placeholder != null && m_Placeholder.TryGetComponent<ILayoutElement>(out var e) && e.preferredWidth > preferredWidth)
|
||||||
|
preferredWidth = e.preferredWidth;
|
||||||
|
|
||||||
|
return preferredWidth + horizontalPadding; // Should add some extra padding for caret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4556,7 +4561,12 @@ namespace TMPro
|
|||||||
if (m_TextViewport != null)
|
if (m_TextViewport != null)
|
||||||
verticalPadding += m_TextViewport.offsetMin.y - m_TextViewport.offsetMax.y;
|
verticalPadding += m_TextViewport.offsetMin.y - m_TextViewport.offsetMax.y;
|
||||||
|
|
||||||
return m_TextComponent.preferredHeight + verticalPadding;
|
var preferredHeight = m_TextComponent.preferredHeight;
|
||||||
|
|
||||||
|
if (m_Placeholder != null && m_Placeholder.TryGetComponent<ILayoutElement>(out var e) && e.preferredHeight > preferredHeight)
|
||||||
|
preferredHeight = e.preferredHeight;
|
||||||
|
|
||||||
|
return preferredHeight + verticalPadding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user