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. Dismiss Notice

Low FPS because of UI

Discussion in '2D' started by codeedward, Nov 5, 2015.

  1. codeedward

    codeedward

    Joined:
    Dec 19, 2014
    Posts:
    93
    Hi

    I have problem with my game. Everything works very good except UI.
    I use Unity UI to show things like buttons, popups, windows to user, but my frame rate fall down when I simply show big popup with transparent black background, white content and some icons + text on the screen.

    I noticed that if I add only one white background to the screen it eats from 5 to 10 fps. It is horrible!
    Is that really such a big thing to Unity?

    What should I do with worse devices?
    Is there any way to improve performance and make fps higher? Scaling, quality, building options..., anything?

    System: Android
    Device: Tablet

    If you need any other informations please let me know.
     
  2. rchmiel

    rchmiel

    Joined:
    Apr 5, 2015
    Posts:
    49
    Try to use GUI.DrawTexture in manual.
    This code displays big texture on full screen - test and let me know :)
    Code (csharp):
    1. public Texture2d someTexture; // small black quad, not transparent
    2.  
    3. void OnGUI() {
    4.    GUI.color.a = 0.3; // transparent scale
    5.    GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), someTexture);
    6.    GUI.color.a = 1; // not transparent for the rest gui element
    7. }
     
  3. codeedward

    codeedward

    Joined:
    Dec 19, 2014
    Posts:
    93
    Hi, thank you for your advice :)
    Hmm, I use Unity new UI system with Canvases. Isn't your way be obsolete?
     
  4. rchmiel

    rchmiel

    Joined:
    Apr 5, 2015
    Posts:
    49
    UI system is very easy to use and this is his main goal. UI has has many options but you may be unnecessary. Unfortunately engine doesn't know of this and uses power. Better make own code only for what you need. In my opinion of course.
     
  5. codeedward

    codeedward

    Joined:
    Dec 19, 2014
    Posts:
    93
    On the other hand can I turn off these unneeded options? And can you list all of them?
    Sometimes views are complicated, like popup with settings or interactive tutorials. It'll takes ages to draw everything using OnGUI method. I tried this when it was Unity 4.5, and especially scaling to device screen was horrible.
     
  6. cmbadv

    cmbadv

    Joined:
    Aug 3, 2015
    Posts:
    1
    Try to use some material with transparent shader instead of sprite. Scaled a lot sprites cause significant perfomance drop.
     
  7. rchmiel

    rchmiel

    Joined:
    Apr 5, 2015
    Posts:
    49
    This same problem is with Unity Terrain - easy and nice tool to modification mesh terrain inside engine. Unfortunately he eats many draw calls which they degrades performance. And again, best to do it yourself in other program.
     
  8. codeedward

    codeedward

    Joined:
    Dec 19, 2014
    Posts:
    93
    @rchmiel
    Do you mean another package like NGUI or another program like Unreal Engine?


    I have changed only one background from sprite to material and FPS dramaticlly fell down. So it looks to be even worse solution in my case.
     
    Last edited: Nov 7, 2015
  9. rchmiel

    rchmiel

    Joined:
    Apr 5, 2015
    Posts:
    49
    I wrote about the mesh, so I mean 3ds or blender.


    How much have these UI ??
     
  10. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    832
    In general, using any kind of transparency will eat draw calls. Try to cut down the amount of transparent pixels you are drawing to the screen, for the fullscreen overlay, try using render layers. You can debug draw calls by using the frame debugger and find the reason for your slow down using the profiler.
     
    codeedward likes this.
  11. codeedward

    codeedward

    Joined:
    Dec 19, 2014
    Posts:
    93
    Correct me if I will say false but profiler is only in Unity Pro? Isn't it?

    I spent whole day to learn New GUI and creating new testing scene to comparison. Just look at this:

    Unity UI performance:
    1. just screen = 27.5fps
    2. with popup = 17.5fps

    NGUI performance:
    1. just screen = 60fps
    2. with popup = 60fps

    It was shock for me. Why Unity is so slow and we have to buy other packages just for UI..

    @rchmiel - I am not very familiar with meshes. Could you tell me what object/component should I use and how can I create it?

    @hawken - Did you mean culling mask on the camera?
     
  12. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    832
    it's in unity personal 5.x
     
    codeedward likes this.
  13. codeedward

    codeedward

    Joined:
    Dec 19, 2014
    Posts:
    93
    Thank you. I didn't know that personal have this already. In my case it is all because of Call Draws.