Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  3. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

TextMesh Pro Text not being updated when using SetCharArray

Discussion in 'Unity UI & 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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    815
    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