Search Unity

TextMesh Pro Changing Font in TextMeshPro changes material of line renderer

Discussion in 'UGUI & TextMesh Pro' started by egonaraujo, Jan 21, 2020.

  1. egonaraujo

    egonaraujo

    Joined:
    Jan 21, 2015
    Posts:
    18
    I work for a company that is basically creating an engine using Unity..

    One of the possible objects the user can use is a "Text Box", which uses a TextMesh Pro to display text.

    Recently, I added a change on it so we could see the colliders inside this engine we are building, so I have a Line Renderer on my Text Box object.

    Problem is, whenever a call to change "TextMeshPro.font" is made, it searches through the object and finds the first Renderer, which is the LineRenderer I have to display colliders, and not the MeshRenderer that TextMeshPro is looking for.

    Is there a way I can change TMP code or a hack I can use to set the MeshRenderer correctly, without messing my other objects?
    upload_2020-1-21_17-24-39.png

    Thanks!

    (PS. Order of behaviors were changed to be usable for print, in the first panel the line renderer is above the mesh renderer. In the second one I manually change the errors)
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Having two different renderers on the same object could potentially results in unforeseen issues. This is not something that I have tested.

    Is the functionality provided by the Line Renderer for your use case only used in the Editor or is it used at Runtime?

    For debugging purposes, there is the TMP_TextInfoDebugTool.cs script that is included in the TMP Examples & Extras. This script which can be added to a text object does draw bounds for characters, words, etc. Perhaps a similar implementation could be used instead of using a Line Renderer.
     
  3. egonaraujo

    egonaraujo

    Joined:
    Jan 21, 2015
    Posts:
    18
    It is used at Runtime (well.. Editor time of the finished engine is Runtime of Unity Engine)

    I have just checked the file you talked about, but Gizmos would not work for me in this case... I am modifying the code so the LineRenderer will only be added to the object after the text label has been fully configured.

    Thanks for the fast response