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

Load lots of resources effectively in the Editor

Discussion in 'Editor & General Support' started by prisonerjohn, Jan 26, 2019.

  1. prisonerjohn

    prisonerjohn

    Joined:
    Jul 31, 2013
    Posts:
    28
    Hello,

    I'm having a bit of trouble figuring out the best approach for loading lots of heavy resources in the Editor. I'm working on a project that is going to be fully set up in Editor, where we need to load about 500 sequences of OBJ meshes and JPG textures. These are used as frames for playback, all controlled using Timeline.

    As there are a lot of sequences to go through, I've been trying to automate this using Editor scripts, and loading my arrays of meshes and textures dynamically. So I'm putting everything in the Resources folder and running something along the lines of:

    Code (CSharp):
    1.  
    2. _meshes = Resources.LoadAll<Mesh>(_mshDir);
    3. _textures = Resources.LoadAll<Texture>(_texDir);
    4.  
    This was all working fine up until a certain point, and now my Editor has become pretty much unusable. It seems frozen, but it's definitely doing something, I'm just not sure what as I'm getting no visual feedback.

    I've been reading online that everything in Resources gets loaded to memory, so my guess is that there's just too much in there for the amount of RAM on my PC, and it's just swapping data non stop... If I take the files out of Resources and restart Unity, it becomes usable again (after taking a long time to reimport everything that moved), but now I have no way of populating my arrays in script...

    What is the best approach for achieving this?
     
  2. ans_unity

    ans_unity

    Unity Technologies

    Joined:
    Oct 12, 2017
    Posts:
    124
    Hi prisonerjohn!
    We would recommend breaking down into multiple timelines and multiple scenes. One timeline will try to load everything, which as he points out is just too much in editor. Then have something which asyncloads / unloads scenes.
     
  3. prisonerjohn

    prisonerjohn

    Joined:
    Jul 31, 2013
    Posts:
    28
    So does everything need to live inside Resources? Does Unity try to load and keep everything from the Resources folder in RAM, or what's going on exactly?

    And what do you mean by too much in Editor? Is there a difference if everything is loaded in a single scene vs everything loaded in different additive scenes?