Search Unity

Bug Updating Unity broke TMPro

Discussion in 'UGUI & TextMesh Pro' started by Wattosan, May 17, 2021.

  1. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    Hello,

    We were using Unity 2019.4.14f1 and updated to 2019.4.26f1. We are using version 2.1.4 of TMPro.

    1. After this we got errors that _HorizontalAlignmentOptions and _VerticalAlignmentOptions does not exist in the context.
    2. Also, it seems the TextMeshProUGUI.SetText(string) method is removed.

    Firstly, why did these stop working after Unity update? Are there define symbols that resulted in this?
    Secondly, why was there no deprecation warning?
    Third, why remove the .SetText(string) overload?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The SetText() function was not removed and both horizontalAlignment and verticalAlignment properties as well as those
    HorizontalAlignmentOptions and VerticalAlignmentOptions are still present.

    As I have seen a few times, it is possible the package cache contained in the Library folder got confused which might be causing these issues.

    BTW: The latest package release for 2019.4 is version 2.1.6.
     
  3. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    _HorizontalAlignmentOptions and _VerticalAlignmentOptions are not removed. They were renamed to HorizontalAlignmentOptions and VerticalAlignmentOptions. SetText() was not removed but its overload of SetText(string) seems to be removed. SetText(string, bool) still exists. For now, I created an extension method.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You are correct in the sense that SetText(string) was consolidated with SetText(string, bool) where the bool is an optional parameter. As such, SetText(string) should still work as it previously did. Does it not?
     
  5. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    Our use case is that we pass a method as a parameter via delegates. The delegate is in the form "void function_name(string)". The passed method is TMPro's SetText(string). Since that overload was deleted, the passed method had a different signature (string, bool) than what is required (string). This broke the compatibility.
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I can revive that function and mark as obsolete the SetText(string, bool) as the bool is no longer used.

    I'll make the change in the next package release.
     
    Wattosan likes this.
  7. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    Sorry to revive this but I just realized, that removing SetText(string) overload also broke every use case, where Unity Events in the inspector were used in conjunction with the TMPro component and the dynamic use of SetText() method.

    Please be a little bit more careful in the future when you deprecate, without warning, methods compatible with the UnityEvent system.
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I will deprecate the SetText(string, bool) since the bool no longer does anything and add back the SetText(string).