Class TextMeshProUGUI
Inheritance
Inherited Members
Namespace: TMPro
Syntax
[ExecuteInEditMode]
[DisallowMultipleComponent]
[RequireComponent(typeof(RectTransform))]
[RequireComponent(typeof(CanvasRenderer))]
[AddComponentMenu("UI/TextMeshPro - Text (UI)", 11)]
public class TextMeshProUGUI : TMP_Text, ICanvasElement, IClippable, IMaskable, IMaterialModifier, ILayoutElement
Fields
m_subTextObjects
Declaration
[SerializeField]
protected TMP_SubMeshUI[] m_subTextObjects
Field Value
| Type | Description |
|---|---|
| TMP_SubMeshUI[] |
Properties
autoSizeTextContainer
Determines if the size of the text container will be adjusted to fit the text object when it is first created.
Declaration
public override bool autoSizeTextContainer { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Overrides
canvasRenderer
Reference to the CanvasRenderer used by the text object.
Declaration
public CanvasRenderer canvasRenderer { get; }
Property Value
| Type | Description |
|---|---|
| CanvasRenderer |
maskOffset
Sets the masking offset from the bounds of the object
Declaration
public Vector4 maskOffset { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector4 |
materialForRendering
Get the material that will be used for rendering.
Declaration
public override Material materialForRendering { get; }
Property Value
| Type | Description |
|---|---|
| Material |
Overrides
mesh
Reference to the Mesh used by the text object.
Declaration
public override Mesh mesh { get; }
Property Value
| Type | Description |
|---|---|
| Mesh |
Overrides
Methods
AdjustLineOffset(Int32, Int32, Single)
Declaration
protected override void AdjustLineOffset(int startIndex, int endIndex, float offset)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | startIndex | |
| System.Int32 | endIndex | |
| System.Single | offset |
Overrides
Awake()
Declaration
protected override void Awake()
Overrides
CalculateLayoutInputHorizontal()
Function called by Unity when the horizontal layout needs to be recalculated.
Declaration
public void CalculateLayoutInputHorizontal()
Implements
CalculateLayoutInputVertical()
Function called by Unity when the vertical layout needs to be recalculated.
Declaration
public void CalculateLayoutInputVertical()
Implements
ClearMesh()
Function to clear the geometry of the Primary and Sub Text objects.
Declaration
public override void ClearMesh()
Overrides
ComputeMarginSize()
Update the margin width and height
Declaration
public override void ComputeMarginSize()
Overrides
Cull(Rect, Boolean)
Override of the Cull function to provide for the ability to override the culling of the text object.
Declaration
public override void Cull(Rect clipRect, bool validRect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | clipRect | |
| System.Boolean | validRect |
ForceMeshUpdate()
Function to force regeneration of the mesh before its normal process time. This is useful when changes to the text object properties need to be applied immediately.
Declaration
public override void ForceMeshUpdate()
Overrides
ForceMeshUpdate(Boolean)
Function to force regeneration of the mesh before its normal process time. This is useful when changes to the text object properties need to be applied immediately.
Declaration
public override void ForceMeshUpdate(bool ignoreInactive)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | ignoreInactive | If set to true, the text object will be regenerated regardless of is active state. |
Overrides
GenerateTextMesh()
This is the main function that is responsible for creating / displaying the text.
Declaration
protected override void GenerateTextMesh()
Overrides
GetCompoundBounds()
Method returning the compound bounds of the text object and child sub objects.
Declaration
protected override Bounds GetCompoundBounds()
Returns
| Type | Description |
|---|---|
| Bounds |
Overrides
GetMaterial(Material)
Declaration
protected override Material GetMaterial(Material mat)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | mat |
Returns
| Type | Description |
|---|---|
| Material |
Overrides
GetMaterials(Material[])
Method returning instances of the materials used by the text object.
Declaration
protected override Material[] GetMaterials(Material[] mats)
Parameters
| Type | Name | Description |
|---|---|---|
| Material[] | mats |
Returns
| Type | Description |
|---|---|
| Material[] |
Overrides
GetModifiedMaterial(Material)
Declaration
public override Material GetModifiedMaterial(Material baseMaterial)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | baseMaterial |
Returns
| Type | Description |
|---|---|
| Material |
GetPaddingForMaterial()
Get the padding value for the currently assigned material.
Declaration
protected override float GetPaddingForMaterial()
Returns
| Type | Description |
|---|---|
| System.Single |
Overrides
GetPaddingForMaterial(Material)
Get the padding value for the currently assigned material.
Declaration
protected override float GetPaddingForMaterial(Material mat)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | mat |
Returns
| Type | Description |
|---|---|
| System.Single |
Overrides
GetSharedMaterials()
Method returning an array containing the materials used by the text object.
Declaration
protected override Material[] GetSharedMaterials()
Returns
| Type | Description |
|---|---|
| Material[] |
Overrides
GetTextContainerLocalCorners()
Method to return the local corners of the Text Container or RectTransform.
Declaration
protected override Vector3[] GetTextContainerLocalCorners()
Returns
| Type | Description |
|---|---|
| Vector3[] |
Overrides
GetTextInfo(String)
Function used to evaluate the length of a text string.
Declaration
public override TMP_TextInfo GetTextInfo(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text |
Returns
| Type | Description |
|---|---|
| TMP_TextInfo |
Overrides
InternalCrossFadeAlpha(Single, Single, Boolean)
Tweens the alpha of the CanvasRenderer color associated with this Graphic.
Declaration
protected override void InternalCrossFadeAlpha(float alpha, float duration, bool ignoreTimeScale)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | alpha | Target alpha. |
| System.Single | duration | Duration of the tween in seconds. |
| System.Boolean | ignoreTimeScale | Should ignore Time.scale? |
Overrides
InternalCrossFadeColor(Color, Single, Boolean, Boolean)
Tweens the CanvasRenderer color associated with this Graphic.
Declaration
protected override void InternalCrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | targetColor | Target color. |
| System.Single | duration | Tween duration. |
| System.Boolean | ignoreTimeScale | Should ignore Time.scale? |
| System.Boolean | useAlpha | Should also Tween the alpha channel? |
Overrides
LoadFontAsset()
Declaration
protected override void LoadFontAsset()
Overrides
OnCanvasHierarchyChanged()
Declaration
protected override void OnCanvasHierarchyChanged()
Overrides
OnDestroy()
Declaration
protected override void OnDestroy()
Overrides
OnDidApplyAnimationProperties()
Declaration
protected override void OnDidApplyAnimationProperties()
Overrides
OnDisable()
Declaration
protected override void OnDisable()
Overrides
OnEnable()
Declaration
protected override void OnEnable()
Overrides
OnRectTransformDimensionsChange()
Declaration
protected override void OnRectTransformDimensionsChange()
Overrides
OnTransformParentChanged()
Declaration
protected override void OnTransformParentChanged()
Overrides
Rebuild(CanvasUpdate)
Declaration
public override void Rebuild(CanvasUpdate update)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityEngine.UI.CanvasUpdate | update |
Overrides
RecalculateClipping()
Method called when the state of a parent changes.
Declaration
public override void RecalculateClipping()
Overrides
RecalculateMasking()
Method called when Stencil Mask needs to be updated on this element and parents.
Declaration
public override void RecalculateMasking()
Overrides
SetActiveSubMeshes(Boolean)
Method to Enable or Disable child SubMesh objects.
Declaration
protected override void SetActiveSubMeshes(bool state)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | state |
Overrides
SetAllDirty()
Declaration
public override void SetAllDirty()
Overrides
SetArraySizes(Int32[])
Declaration
protected override int SetArraySizes(int[] chars)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32[] | chars |
Returns
| Type | Description |
|---|---|
| System.Int32 |
Overrides
SetCulling()
Declaration
protected override void SetCulling()
Overrides
SetFaceColor(Color32)
Declaration
protected override void SetFaceColor(Color32 color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color32 | color |
Overrides
SetLayoutDirty()
Declaration
public override void SetLayoutDirty()
Overrides
SetMaterialDirty()
Declaration
public override void SetMaterialDirty()
Overrides
SetOutlineColor(Color32)
Declaration
protected override void SetOutlineColor(Color32 color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color32 | color |
Overrides
SetOutlineThickness(Single)
Declaration
protected override void SetOutlineThickness(float thickness)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | thickness |
Overrides
SetShaderDepth()
Declaration
protected override void SetShaderDepth()
Overrides
SetSharedMaterial(Material)
Declaration
protected override void SetSharedMaterial(Material mat)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | mat |
Overrides
SetSharedMaterials(Material[])
Method used to assign new materials to the text and sub text objects.
Declaration
protected override void SetSharedMaterials(Material[] materials)
Parameters
| Type | Name | Description |
|---|---|---|
| Material[] | materials |
Overrides
SetVerticesDirty()
Declaration
public override void SetVerticesDirty()
Overrides
UpdateFontAsset()
Declaration
public void UpdateFontAsset()
UpdateGeometry(Mesh, Int32)
Function to update the geometry of the main and sub text objects.
Declaration
public override void UpdateGeometry(Mesh mesh, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | mesh | |
| System.Int32 | index |
Overrides
UpdateMaterial()
Declaration
protected override void UpdateMaterial()
Overrides
UpdateMeshPadding()
Function to be used to force recomputing of character padding when Shader / Material properties have been changed via script.
Declaration
public override void UpdateMeshPadding()
Overrides
UpdateVertexData()
Function to upload the updated vertex data and renderer.
Declaration
public override void UpdateVertexData()
Overrides
UpdateVertexData(TMP_VertexDataUpdateFlags)
Function to upload the updated vertex data and renderer.
Declaration
public override void UpdateVertexData(TMP_VertexDataUpdateFlags flags)
Parameters
| Type | Name | Description |
|---|---|---|
| TMP_VertexDataUpdateFlags | flags |