Search Unity

TextMesh Pro Does TMP cache the content text ?

Discussion in 'UGUI & TextMesh Pro' started by haolly, Jul 27, 2018.

  1. haolly

    haolly

    Joined:
    Sep 8, 2015
    Posts:
    15
    I found when I send the same text to TMP, the first time will take same time , but the second time takes little time .
    So I guess TMP use some cache policy to cache every single character so when the same content is set again, it will not build the new text mesh ?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    TMP does check if the text or any other properties have changed and if everything is the same, it won't regenerate the text object.

    Independently of that, the first time a text object is generated, some buffers need to be allocated which does add some overhead. However, once these have been allocated (in blocks) and provided the length of the text doesn't change and exceed the capacity of the new buffer, the subsequent generations will be faster.