Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

TextMesh Pro ForceMeshUpdate(true) not working when object inactive

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by DED-Games, Apr 1, 2018.

  1. DED-Games

    DED-Games

    Joined:
    Nov 1, 2010
    Posts:
    140
    I'm trying to assign a text to an inactive TextMesh Pro text object, and then get the text info with
    textInfo
    . Before accessing
    textInfo
    , I call
    ForceMeshUpdate(true)
    to update the object; I would expect setting the parameter
    ignoreActiveState
    to
    true
    would update the object even if it's inactive, but it doesn't. Am I misinterpreting the parameter, or is it a bug?:

    Code (CSharp):
    1. textComponent.text = text;
    2. textComponent.ForceMeshUpdate(true);
    3. numCharsFromTextInfo = textComponent.textInfo.characterCount; // Returns incorrect data
    For now it seems activating the object just before updating and deactivating it afterward works, but it's not very nice, and doesn't work if one of the parent objects is inactive.
     
    Last edited: Apr 1, 2018
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,049
    Thank you for taking the time to provide feedback.

    I'll take a look and make the necessary changes if required.
     
  3. DED-Games

    DED-Games

    Joined:
    Nov 1, 2010
    Posts:
    140
    Thanks. By the way, I may have found a pair of other things that look like bugs, should I report them from Unity's bug report tool?
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,049
    It is up to you.

    If these are trivial and easily reproducible, you can report them here. If they are more challenging to reproduce, then submitting a bug report with Repro case is always best as I can focus on a solution as opposed to trying to reproduce something.
     
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,049
    I have addressed the incorrect behavior of the ForceMeshUpdate(bool ignoreActiveState). This change will be included in the next release of TMP.
     
  6. shell123

    shell123

    Joined:
    May 26, 2016
    Posts:
    4
    Was this fixed? I am still running into it. When the gameobject is inactive at the time of a ForceMeshUpdate(true) call the bounds are not updated. When the gameobject is active at the time of a ForceMeshUpdate(true) call the bounds are updated correctly.
     
  7. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,049
    What version of TMP are you using?

    This should be working but once you let me know what version you are using, I can double check on my end.
     
  8. shell123

    shell123

    Joined:
    May 26, 2016
    Posts:
    4
    I am using 1.3.0.
     
  9. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    474
    I'm seeing this behaviour in 1.2.4.

    I instantiate a prefab with a TextMeshProUGUI component and parent it to another game object. activeSelf is true, but activeInHierarchy is false. I set the text field, then call ForceMeshUpdate(true) but the preferredHeight is not updated and the textInfo field still has the character count of the original text on the prefab. Using Unity 2018.2.12f1. I've also tried calling SetAllDirty but no dice.

    edit: I updated to 1.3.0 but still no luck!

    Thanks,
    Sam
     
  10. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,049
    Let me take a look at this again. I should be able to get you an update tomorrow.
     
  11. WF_Bart

    WF_Bart

    Joined:
    Apr 16, 2014
    Posts:
    20
    Any update on this? I'm running into the same problem (also on 1.3.0)
     
  12. jk314

    jk314

    Joined:
    Jun 23, 2011
    Posts:
    46
    Happening to me also.
     
  13. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,049
    I did address this issue in the current version of the TMP package that I am working on which hasn't been released yet.

    The release that will include the change will be 1.4.2 for Unity 2018.3 and 2.0.2 for Unity 2019.1 or newer.

    I will try to lookup the specific changes and if they can be easily made in 1.3.0, will post those in the next few days.

    Please feel free to re-post in this thread, if I don't provide an update on this within the next few days.
     
  14. giawa

    giawa

    Joined:
    Dec 6, 2015
    Posts:
    8
    Seeing this in 1.3.0 in Unity 2018.2. Cant update my version of Unity at this time. Is there a work around?
     
  15. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,049
    I would suggest taking a look at the revised ForceMeshUpdate() in version 1.4.1 (since the source code is included with packages) and making the relevant changes on your end.
     
  16. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    266
    Hi had this same issue with the bounds not updating correctly so I invoke a method a frame later and that seems to fix things.