Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Enabling and Disabling Canvas causes TMP to GenerateTextMesh()

Discussion in 'UGUI & TextMesh Pro' started by HugeWill, Feb 7, 2022.

  1. HugeWill

    HugeWill

    Joined:
    Nov 4, 2016
    Posts:
    27
    Hi,

    Instead of setting the parent GameObject to on/off we enable/disable the canvas attached as it's more efficient.
    The problem we are encountering is that when enabling/disabling the canvas OnCanvasHierarchyChanged() is called which in turn marks the TMP component for graphic rebuild.

    We have lots of TMP components on the canvas, but they don't need their text regenerating as they aren't changing, however the automatic dirtying is causes them to be regenerated.

    Is there any way to avoid the rebuild happening?

    Thanks,
    Will
     
    mfakkaya likes this.
  2. HugeWill

    HugeWill

    Joined:
    Nov 4, 2016
    Posts:
    27
  3. HugeWill

    HugeWill

    Joined:
    Nov 4, 2016
    Posts:
    27
    As an experiment I just added in a return to the OnCanvasHierarchyChanged() so that when the canvas is enabled/disabled the text isn't dirtying, which reduced the time massively. However, this is just a hacky way to prove that the text didn't need regenerating, and comes with other problems.

    upload_2022-2-8_8-54-46.png
     
  4. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    Did you ever resolve this?
     
  5. immerVR

    immerVR

    Joined:
    Jan 23, 2020
    Posts:
    6
    Seems to be still an issue in Unity 2021.3.10f1.