Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro Text not being updated when using SetCharArray

Discussion in 'UGUI & TextMesh Pro' started by xellfish, Jul 17, 2017.

  1. xellfish

    xellfish

    Joined:
    May 25, 2014
    Posts:
    10
    I already posted a similar question in the text mesh thread, but I figured it might be better to open a thread here.

    There seems to be a small bug in TMP_Text.SetCharArray(char[]). Setting the text using that method doesn't seem to update the component. Quick glance into the assembly reveals that this method is not calling SetVerticesDirty and SetLayoutDirty like all of it's brethren do, and calling those two methods manually after setting the array will indeed update the component correctly.

    I would also like to ask if it would be possible to add a method with the signature SetCharArray(char[], int start, int length). This would be very helpful when working with custom char buffers (which in turn help avoid the garbage inherhent to using strings or StringBuilders). There already exists SetCharArray(int[], int start, int length), but it only accepts int arrays, and to my knowledge it's not possible to cast char arrays to int arrays without allocating a new array. Should only be a minor variation of the existing methods, so that would be great.

    Using version 1.0.55.2017.1.0b11 and Unity 2017.1.0f3

    Thanks
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Let me take a look at the update issue as well as the addition of an overload for SetCharArray()

    Update
    I fixed the issue you reported as well as added the new overload to SetCharArray(char[] array, int start, int length);

    These changes will be in the next release.
     
    Last edited: Jul 18, 2017