Search Unity

[Solved] Instantiate UI kills framerate

Discussion in 'UGUI & TextMesh Pro' started by MSplitz-PsychoK, Jun 30, 2016.

  1. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    Hello,

    I'm working on a fast-paced arena game with 4 players competing to reach the highest score. It is very important for player feedback that score text is displayed when a player does something good (ex. show "+300" when they score 300). As soon as I added that "floating score" functionality, the framerate dropped to the point where the game is unplayable.

    This is a bit baffling because my game is heavy on effects: I use grab passes to create screen-space distortion and use a lot of particles and other gameobjects being instantiated (up to about 10 objects instantiated per second, including effects). I also have probably have about 25+ tweens executing from DOTween (on the asset store).

    I know the floating UI text is the problem because I get 60 fps when I comment it out, and 20 when I don't. Floating text should not be this expensive... any ideas?


    (Text is UI Text that is positioned based on a Camera.WorldToScreenPoint() from a 3D object's position)
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    Solved the problem.

    The UI text tweens it's scale and color. When the UI text increased in size, the font texture would be rebuilt several times to compensate the change in size. Using a non-dynamic character set with my font fixed the problem.