Search Unity

How do I optimize my game and how to enable GPU rendering

Discussion in 'General Graphics' started by MikeyJY, May 25, 2020.

  1. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    I noticed that my game is very laggy and I don't know why. I opened profiler, but I not sure that I'm able to read it, so I recorded the profiler, so someone can tell me how to optimize:


    I know that after building performance is improved, but I think there is room for better.
    I noticed that in the profiler it says: "CPU:2,360.67ms, GPU: --ms" and maybe I'm using Intel Graphics instead of nVIDIA graphics card for rendering. I'm not sure, but I think there is an option to tell unity which to use.

    Anyway, my PC is not a high-performance computer, but I think i'm should be able to play my game at 60 FPS.
    My GPU is nVIDIA 930, and also my CPU is Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz.

    I'm not that good at hardware I'm more with software.
     
  2. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    At 33 secs in the vid, I noticed you have 540 drawcalls and 540 batches, which is way too much, and could be the cause of the slow down in your game. Use some texture atlases, and batch some objects together, to help reduce those drawcalls and batches.

    Also, use dynamic batching or static batching accordingly, to help make your game run faster. Read up on those two things I mentioned in the Unity manual.

    https://docs.unity3d.com/Manual/DrawCallBatching.html
     
    Last edited: May 25, 2020
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    You might be using the Intel GPU instead of the dedicated one, I can't tell from this, you'd have to check your NVidia control panel for that (I've also got a Systray icon of a gray chip that turns green when the NVidia chip takes over)

    The Profiler displays GPU: --ms if no GPU timings have been collected. You'd have to add the GPU Profiler module to it and see if your chosen graphics API is supported (e.g. DirectX should be supported but the GPU Profiler module will tell either show you data or tell you why it couldn't in 2019.3 or newer versions).

    Also, that's quite a lot of time spend in "Others" which could mean your performance problems are due to something in the Editor and not (necessarily) in your game. Make a build and Profile that. Also check out the Profiler Documentation and the recent unite now session on profiling to get started :)

    Also, yes that many drawcalls might well cause issues, particularly on older& slower hardware. A well optimized game would probably run ok on it though.
     
  4. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    Thanks you a lot @BrandyStarbrite and unity technologies. But how to profile a built project?
     
  5. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    O and I have some null references. may this affect the performance?
    And [SerializableField] affect? beacause I have some public variables that can be private
     
    Last edited: May 25, 2020
  6. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    You make a development build (with or without Autoconnect profiler option) and then you run it and connect the Profiler (or let it connect automatically. The documentation has the finer details, and that Unite now talk also gets into some other tools that might be helpful for you in this case, like the frame debugger.
     
  7. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    Debug logs affect performance, whether that's due to errors, warnings or you logging something. This usually starts to be noticable if it's multiple logs per frame.
     
    BrandyStarbrite likes this.
  8. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    thank you again. I wish at 60 fps