Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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.