Search Unity

Keeping assets loaded (Optimization)

Discussion in 'Scripting' started by chees502, Oct 20, 2014.

  1. chees502

    chees502

    Joined:
    Jan 25, 2014
    Posts:
    22
    I have a mesh, with a lot of triangles, and expensive material information, and I am needing to hide the render of it. Since it is so expensive of an asset the act of loading it back into the memory cause a frame hiccup.

    Is there a way to force a mesh and all of it's assets to remain loaded in memory , while being able to "turn it off"?
     
  2. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
    Disabling the MeshRenderer will stop the mesh from displaying. Everything else will still be the same.
    Code (csharp):
    1. public void Hide()
    2. {
    3.   renderer.enabled = false;
    4. }
     
  3. chees502

    chees502

    Joined:
    Jan 25, 2014
    Posts:
    22
    That will unload it from memory (both host and GPU) that is what is causing my issue. I need to have it not visible, but still fully loaded, avoid unity.
     
  4. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Put it on a layer that isn't rendered by the camera. Note that this will cause it to still incur culling costs etc.