Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Fast in editor, VERY slow in game.

Discussion in 'Editor & General Support' started by kinetiknz, Jun 6, 2012.

Thread Status:
Not open for further replies.
  1. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    Hey I have a fairly simple scene, involving a house and simple environment. It displays very fast in the editor, even with AA and fairly high res (large scene view) When playing however the FPS are very low.

    I have some simple logic - using Playmaker to control certain things, nothing complex as I understand.

    My first thought is that the scripts are using a huge amount of resources, though I don't see a huge demand in the profiler.

    Does anyone have thoughts as to the massive performance difference?
     
  2. UnityCoder

    UnityCoder

    Joined:
    Dec 8, 2011
    Posts:
    534
    You have to do some optimization in ur scene.

    1.Use Occlusion culling in ur scene.

    2.Use lightmap for shadow instead of real shadow.

    3.Use combine children if necessory.

    4.Remove unneccesory GameObject.Find from ur scripts.

    5.Reduce ur texture size.

    and last watch that Unite optimization video.
     
  3. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    Thanks Ram,
    There is no dynamic lighting, or culling. Culling would have a minimal effect, as most is visible at all times anyhow.

    I will look into combine children. and the optimise video. It perplexes me that the editor should be SO much faster though. If anything I would expect the editor to be slower in a scenario with very little run-time scripting.


     
  4. MADmarine

    MADmarine

    Joined:
    Aug 31, 2010
    Posts:
    627
    Your assumptions are correct, the editor should run slower than the application, I think Ram Thakkar misunderstood your problem.

    You haven't accidentally ticked "Development Build" in the build settings have you?

    And also make sure you run the application at the same resolution and quality level as in the editor. If you application is running full screen at 1920x1080 at fantastic quality while in the editor you're at 1024x768 at good quality, it's not surprising the application is running slower.
     
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    Please define "very low".
     
  6. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    Thanks for the replies, I'm only using 1 quality setting, and the issue seems to be the same in 'game' as well as in the build.

    I have just noticed one very strange thing though. I left the build playing for a while last night, and at some point, about 2 or 3 minutes into it, the speed dramatically increased to match the editor speed.

    Nothing of consequence happens at that point, like an event/scene change/script beginning/ending etc

    Puzzling.
     
  7. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    Check your log file.

    Also, to be clear: you're finding that a build is slower than the Game view in the editor, correct?
     
  8. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    Hey, The game and build are always the same speed, slow, then suddenly change to fast. The editor is constantly fast.
     
  9. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    No, see, that's a confusing thing you've just said, because "the game" must mean either "the build" or "the editor."

    Please pick one of the two possibilities for each of the following three scenarios:

    • In the Unity Editor's "Scene View" window: Starts slow, or starts fast?
    • In the Unity Editor's "Game View" window: Starts slow, or starts fast?
    • In a standalone build, running independently of the Unity editor: Starts slow, or starts fast?
     
  10. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173

    Sorry, I mean this:
    Scene view - fast always
    Game view - slow then fast
    Build - slow then fast

    I'm going to duplicate the entire project and strip out all of the playmaker nodes except the bare minimum and check for a difference. Will post how it goes

    I'm taking a guess, but I think the game playing keyframed animation on a series of animations may be crippling performance.
     
  11. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    OK. Scene View isn't really a relevant test because none of your game logic is run there and it only updates when something changes, so you're only getting rendering cost there. This suggests that the performance hit is coming from something other than rendering - scripts and physics are the usual culprits.

    Unlikely to be animation unless you've got a ridiculous number of bones (or a ridiculous number of characters all being animated). I can run 30 characters with about 50 bones each all with multiple blended animations and still get over 80FPS so consider where you stand in comparison. Unless you mean "keyframed" as in Quake-style full vertex morphed meshes, in which case it may be a factor. I'd expect such things to show up in the profiler though.

    Can you post screencaps of the profiler both when the game is running slowly and the another when it's sped up again?

    Also, have you checked the log file and/or console window output yet?
     
  12. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    Hey yeah I've looked through the LOG, though nothing is standing out yet.
    I stripped out all of the LOGIC - which is basically all of the Playmaker logic and it is instantly 100fps instead of 15fps

    I will go back now and strip it out block by block until I find the culprit.

    By animation data, I mean just camera's animated inside Unity. By the sound of your experience it shouldn't be an issue though.
     
  13. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    OK I have figured it out. I have about 20 cameras in my scene. I assumed that camera's that aren't set to 'main camera' are essentially not drawing.

    So my scene has been drawing 20 camera's at once!!

    Disabling 19 of them instantly fixes. Now I just have to update the PM scripts to enable the camera before switching to it.

    Thanks for the help guys!
     
  14. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    That'll do it :)

    Having multiple cameras is a useful approach if you're doing compositing for your scene - for example, you might have one camera that renders a 3D skybox, then another camera that renders the game world, then another camera that renders the player's FPS gun, then another camera that renders the player's HUD, etc.
     
  15. Modus_Pwnens

    Modus_Pwnens

    Joined:
    Oct 24, 2017
    Posts:
    4
    Wait! I have the issue that you thought this guy had. My game view in the editor runs the game without lag, but once I build the game it runs slowly. What could be causing this?
     
  16. C-T-Y

    C-T-Y

    Joined:
    Nov 12, 2019
    Posts:
    2
    I fixed it by limiting my fps
     
  17. LOSTSOUL86

    LOSTSOUL86

    Joined:
    Apr 17, 2017
    Posts:
    10
    Hi,
    I have actually the same problem. As in the title. The game runs well in editor but it's kind of laggy on the phone.
    The game is very small 40mb. It's simple 2d game. Exported in fastest quality settings in android. No lighting no shadows.
    I checked profiler in the editor but not much of any resources is used. It's only used small fraction of resources as expected fps in editor is 300-500.

    Previously I built this game in Unity 5.5 and it was running smoothly on the phone - perfectly.
    Now I built it on the 2017 unity and the rendering on the phone is so laggy. What else can I check? What may cause the problem. I know there is no issue with algorithm itself it's some kind of rendering settings?
    I am thinking to do 2 things.
    - remote profiling.
    - use unit 2019 instead and try there
     
  18. chrisdonnelly2002

    chrisdonnelly2002

    Joined:
    Jan 14, 2020
    Posts:
    1
    whenever I run my game in the unity editor sometimes it runs smooth and other times sluggish. It also always runs slow without speeding up in the build
     
  19. bobisgod234

    bobisgod234

    Joined:
    Nov 15, 2016
    Posts:
    1,042
    Try using the profiler to help find the issue.
     
  20. sand_lantern

    sand_lantern

    Joined:
    Sep 15, 2017
    Posts:
    210
    Can we get a mod in here to lock this? It's a quagmire of people who think necroing threads will solve their problems.
     
    Joe-Censored likes this.
Thread Status:
Not open for further replies.