Search Unity

TextMesh Pro Modifying glow power on a material preset

Discussion in 'UGUI & TextMesh Pro' started by dodderz, Sep 9, 2018.

  1. dodderz

    dodderz

    Joined:
    Apr 20, 2015
    Posts:
    6
    I have a TextMeshProUGUI and within the text one word is being set to use a different material preset using the <font="" material=""> tag. The replacement material preset has glow enabled. This works fine but I then want to modify the glow power of that material. I tried doing this by modifying the glow power on the material of the sub mesh that gets created for that text but this doesn't seem to do anything (I imagine the value is getting overwritten by textmesh pro itself each frame?)

    What's the correct way to do this? I want to increase the glow over time. Note that the <font> tag is being inserted at runtime if that makes any difference
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    When accessing materials, you have to be mindful that accessing the material directly will result in an instance of a material being created (this is a long established Unity convention) whereas accessing the shared material will affect the material that might be shared by several objects.

    So in this case, it is possible that you end up modifying an instance instead of the shared material.