Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

TextMesh Pro Text not being updated when using SetCharArray

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

  1. xellfish


    May 25, 2014
    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 and Unity 2017.1.0f3

  2. Stephan_B


    Unity Technologies

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

    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