Search Unity

TextMesh Pro Make vertex adjustments permanent

Discussion in 'UGUI & TextMesh Pro' started by uwdlg, Jun 18, 2022.

  1. uwdlg

    uwdlg

    Joined:
    Jan 16, 2017
    Posts:
    150
    Hi,

    based on the "WarpTextExample" script from the TMP examples I wrote a script to position the letters of a TMP_Text on a curve. I would now like to have these mesh adjustments persist in the editor and in play mode, ideally without recalculating the positions frequently. The text doesn't change or move at runtime, is there some way to prevent the mesh from being rebuilt at runtime? If not, when should I call the method to adjust the vertices?
    Thanks!
     
  2. uwdlg

    uwdlg

    Joined:
    Jan 16, 2017
    Posts:
    150
    For anyone in my shoes, I experimented with this and figured out calling the mesh adjustment method in the following cases seems to be the necessary minimum:
    • in
      OnValidate()
      within
      if (!Application.running) {}
      for the editor preview
    • in a listener of the text component's
      OnPreRenderText
      callback for playtime
    Hope that helps some future reader