Search Unity

Losing performance on change of scene.

Discussion in 'Scripting' started by MrZeker, May 30, 2019.

  1. MrZeker

    MrZeker

    Joined:
    Nov 23, 2018
    Posts:
    227
    Hello
    im having a problem. When i start the game in the combat scene (its a fighting style), im having a stable 57-60 fps. but when i start the game from the main menu, im having 45 fps.

    now, i tried to trace it back to why it is, and im almost sure that it is because of the camera and rawimage that i use to showcase the characters when selected. however, those thing shouldnt persist when i change scenes i think. im using Scenemanager.loadscene(1) , to change to scene 1, and i think that destroys everything from scene 0?
    Even in the main menu im a 25 fps when the rawimage and camera are active, which i think is really for only one active object in camera and only one light source. But when i disable the camera i get back to 60 fps.
    Now the thing is, if i start the Mainmenu with the camera disabled, i can run the game at 60fps (in combat mode), but if i start it with the camera enabled, even if i disable the camera, the gameobject where the camera is, the rawimage, or destroy any of those, i still get 45 fps in combat mode.

    at this point i have not idea what to do, or how to fix this. im new at unity, so this may be a commom mistake, but i have spent the last 4 hours trying to find what was lagging the poor game.

    Can someone help me here?
     
  2. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    Have you checked the profiler in both cases to see if you can identify the performance drain?
     
  3. MrZeker

    MrZeker

    Joined:
    Nov 23, 2018
    Posts:
    227

    This is what came up, it is definetly the camera rendering. but i dont understand why it is rendedring in scene 1, when it should be inactive because the camera is from scene 0