Search Unity

How can I speed up Unity's Editor in complicated scenes?

Discussion in 'Editor & General Support' started by Dreamwriter, Apr 14, 2017.

  1. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    I'm using Unity 5.5 64-bit. I have a rather large, complicated scene, and it brings Unity's Editor to a chug - if I don't zoom in on one small part of the scene, everything in Unity, including its menus, runs at a crawl. It's especially bad trying to drag and drop things. So my question is, how can this best be sped up?

    I have a rather powerful computer, so I don't think I can upgrade anything to help - 64GB RAM, i7-6900K @ 3.2Ghz, GTX 1080. I don't have an SSD, but in theory the hard drive shouldn't be involved here. Any ideas?
     
    Last edited: Apr 14, 2017
  2. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    More information, including a workaround:

    First off, I *do* have an SSD :) And, this only happens for the first 10-15 minutes after loading the scene in the editor, eventually it goes away. That includes Unity's first load, or just later opening the scene in the editor (not while running). It's still happening in Unity 5.6.2. I profiled the editor during it, it's all in ExtractGIInstances, called from GISceneManager.UpdateMaterials. Note that we aren't baking GI nor precalculating it, it's all realtime.



    The workaround: press Play to run the game in the editor, then stop it running. That fixes the problem entirely, Unity's editor is responsive after that. Until next time we load the scene.
     
  3. hunterua

    hunterua

    Joined:
    Nov 5, 2009
    Posts:
    42
    Damn, its still exist in 2018.1!
    When I click on any of prefabs in my project it's freeze unity editor for quite long time!
    Impossible to work!
     

    Attached Files:

  4. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    I've encountered same issue, when any static game object with mesh renderer was selected. To fix it, I've unchecked Lightmap static on objects that are spawned in thousands on my scene (sticks, mashrooms, rocks etc.). I use real time lightning, that's why unchecking it wasn't a problem for me.
     
  5. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    I've noticed that some actions like dragging prefab into the scene, still creates a slowdown. The solution is to unchecked those two options.

     
    Meceka likes this.
  6. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    423
    For me, the problem was also related to lighting window.

    Somehow, the Cubemap under Environment Reflections was changed to Default Prefab Mode Skybox (I forgot the name, but was similar to this).
    This isn't an asset in the project folder, I guess it some GI operation fails for this reason.

    It was causing it to have error in ExtractGIInstances method EditorOnly [GetComponentNullErrorWrapper].
    In my case it was creating 2.5gb garbage allocation and hanging editor for 30 seconds.

    Removing this cubemap reference fixed the issue.

    I hope this info. helps someone.
     
  7. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    I am having the same issue. URP, 2020.1. I have ensured I have disabled global illumination and have no environmental reflections cubemap. When I select a prefab that is static and has "Contribute global Illumination" toggled on, it freezes my editor for ~30 seconds, runs for one frame, then freezes again. I have had this issue for at least 6 months to a year.

    Also, I have been unable to repro this in a small project, so I am currently unable to post a bug report. If anyone knows specifically what causes this issue, then that would be amazing. It looks like any sort of error that is thrown in this instance turns into a hellscape of error throwing, but figuring out an example error to actually cause this is needed.

    While we wait, here is a tool that will make all prefabs not contribute GI. I tried using the prefab post processor, but no matter what I did, it wouldn't trigger. Unity is a very stable engine.


    Code (CSharp):
    1.  
    2.         //Tool to fix all current prefabs without reimporting everything :)
    3.         [MenuItem("Tools/Disable ContributeGI On All Prefabs")]
    4.         static void DisableOnAll()
    5.         {
    6.             string[] guids = AssetDatabase.FindAssets("t:Prefab");
    7.  
    8.             foreach (var guid in guids)
    9.             {
    10.                 var target = AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GUIDToAssetPath(guid));
    11.  
    12.                 var renderers = target.GetComponentsInChildren<MeshRenderer>();
    13.  
    14.                 foreach (var renderer in renderers)
    15.                 {
    16.                     var currentFlags = GameObjectUtility.GetStaticEditorFlags(renderer.gameObject);
    17.                     GameObjectUtility.SetStaticEditorFlags(renderer.gameObject, currentFlags & ~StaticEditorFlags.ContributeGI);
    18.                 }
    19.  
    20.             }
    21.          
    22.         }
    23.        
     
    Last edited: Jul 10, 2021
  8. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    423
    I don't remember everything, but I also had a similar issue, I remember that it was happening when duplicating objects or some similar stuff. It was only happening on my project because there are so many different classes. And the way that function (some comparison between object types or something) happens in the background and the length of the hangs was relative to class count squared.

    So in the repro project, you can maybe try having thousands of c# scripts and classes and maybe that will trigger the longer hang which Unity can also experience.

    Edit: Might be related: https://forum.unity.com/threads/ext...s-in-project-2018-3-12f1.661390/#post-5855134
     
    joshcamas likes this.
  9. eggsamurai

    eggsamurai

    Joined:
    Oct 10, 2015
    Posts:
    115
    bump, HDRP 2021.3.7lts, still exists broke all our work