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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Text Flickering on device

Discussion in 'UGUI & TextMesh Pro' started by dustinandrew, May 22, 2015.

  1. dustinandrew

    dustinandrew

    Joined:
    Apr 30, 2010
    Posts:
    102
    I'm seeing some flickering with the uGUI Text, but only on the device. It goes away after you play a few levels. But if you shutdown the game and reopen it, it starts again.

    My canvas is screen space - overlay, pixel perfect, and scale with screen size width.

    I'm using 2 fonts in my UI, Handel Gothic & PEPSI, it appears to only flickering on the text fields using the PEPSI font. Both are set to smooth, dynamic, and include font data.

    Here is a video showing it:
    https://dl.dropboxusercontent.com/u/8682477/Files/Vorteks_Unity5_TextFlickering.mov
    Anyone else seen this? Anyone know a work around?

    Unity 5.0.2f1, iOS 8.3 on an iPad Air, IL2CPP Cloud build

    I reported the bug:
    http://fogbugz.unity3d.com/default.asp?698834_qqcdd0f4g9q5ul1l

    Thanks.
     
    Last edited: May 22, 2015
  2. dustinandrew

    dustinandrew

    Joined:
    Apr 30, 2010
    Posts:
    102
    Has anyone else seen this?
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,744
    It's tough to tell what's going on in the video since the frames have a tendency to blur together. But, it looks like the font's texture map is being recalculated at an inappropriate time - the letters are all in the right place, but the UV's on it are pointing to what is now jibberish. My suspicion is that this recalculation is being triggered by resizing (not scaling, I mean changing the rectTransform.sizeDelta) of any text box that uses the particular font being used on the flickering text.

    I'd look for anything that might be changing those size values, such as perhaps an animation curve that is not quite 100% flat.
     
  4. dustinandrew

    dustinandrew

    Joined:
    Apr 30, 2010
    Posts:
    102
    Thanks. But I'm not resizing anything, just animating the text's gameobject active and doing all that from a coroutine, not an animator. The only thing I can think of, is that the textfields are all set to "Best Fit", which maybe triggers a recalculation of its size when I turn the gameobjects active.
     
  5. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,744
    Yeah, Best Fit might cause that behavior. Does disabling Best Fit make the issue go away?

    As an aside, using Best Fit on text objects when you don't plan on having a variable quantity of text in them is a Bad Thing for performance, particularly if you have it on a lot of different text objects.
     
  6. dustinandrew

    dustinandrew

    Joined:
    Apr 30, 2010
    Posts:
    102
    Thanks. I'll turn it off and see if that was the issue. I'm using Best Fit so that future languages would work in the UI design, but if that's the issue I might have to drop it.
     
  7. dustinandrew

    dustinandrew

    Joined:
    Apr 30, 2010
    Posts:
    102
    Looks like it was because the fonts were set to dynamic, which the docs say, it will create the font spritesheet at runtime if dynamic. http://docs.unity3d.com/Manual/class-Font.html

    So maybe its a bug with dynamic fonts?

    Anyway, changing it to not dynamic, fixed the text flickering issue, but made some of the textfields look blurry and others look a little jaggy, like a large font size scaled down. I think with dynamic, it would create the spritesheets based on the font sizes need with Best Fit. Without dynamic, all fonts are render at the same size, then scaled to fit in the textfield, thus casuing the blurry and jaggy text. Its not bad, but noticeable on high resolution devices.
     
  8. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,744
    Yeah, you've pretty much got it. A workaround for the visual issues of static fonts would be to make duplicates of the font at several font sizes, applying each to the different sizes of text boxes (which is, effectively, what the dynamic font was doing behind the scenes).
     
  9. joolsa

    joolsa

    Joined:
    Mar 20, 2013
    Posts:
    10
    I'm also seeing this - but only when running using Apple's new Metal API. It seems like the synchronisation between the font texture cache render and the main render is broken with that renderer. I'm currently forcing GLES2 as the renderer, which 'fixes' the issue.
     
    StarManta likes this.
  10. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,744
    That's good info. I'll check that setting if I see this bug in the future.
     
  11. xema25

    xema25

    Joined:
    Aug 24, 2013
    Posts:
    37
    So... Any solution for this?


    Using Best Fit?
    Changing Dynamic Fotns?
    In the architecture I always set Universal, is it wrong?

    Thanks
     
  12. feijitouhaha

    feijitouhaha

    Joined:
    Aug 6, 2015
    Posts:
    1
    You may check your canvas and make sure the sort order of your canvases in one scene are not all the same. This may solve the problem.