Ejemplo n.º 1
0
    /// <summary>
    /// Refresh mesh and recalculate thing in TextMeshProUGUI object
    /// Use this after setting new text or size in one of parent RectTransform object.
    /// </summary>
    /// <param name="textMeshProUGUI"> Object to refresh </param>
    private void RefreshTextMeshProUGUI(TextMeshProUGUI textMeshProUGUI)
    {
        // After setting new text, we should use this method to refresh mesh containing text. Found this info on Unity forum
        textMeshProUGUI.ForceMeshUpdate();
        // just a guess, but i think if this is not called after changing text and seting new size for container, then text will be not alligned correctly
        textMeshProUGUI.CalculateLayoutInputHorizontal();

        textMeshProUGUI.ComputeMarginSize(); // Just to be sure
    }