Search Unity

TextMesh Pro fontMaterial getter throw exception if m_sharedMaterial is null

Discussion in 'UGUI & TextMesh Pro' started by sidespin, Jun 21, 2019.

  1. sidespin

    sidespin

    Joined:
    Jun 22, 2018
    Posts:
    20
    I was running a pipeline to check if all the TextMeshProUGUI components are properly set to the correct fontAsset and fontMaterial. And noticed this issue.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    How did you run into this?

    Accessing the fontMaterial property will result in the creation of an instanced material. So this might be why you end up with some error in the event this instanced material is destroyed since it is not persistent.

    To access the persistent material, use fontSharedMaterial.
     
  3. sidespin

    sidespin

    Joined:
    Jun 22, 2018
    Posts:
    20
    I figured. Thanks for the quick response