Search Unity

Memory Usage - GameObject design - Several Animator and SpriteRenderer with different Textures

Discussion in '2D' started by Rockaso, Jan 19, 2020.

  1. Rockaso

    Rockaso

    Joined:
    Oct 31, 2016
    Posts:
    85
    Hello all,
    I have a big memory usage on my game due to Child game objects being disabled but occupying memory space.
    I made my character's prefab to game different child GameObjects with different textures assigned to several SpriteRenderers.

    All childs are Inactive and I use SetActivate to activate the one I need depending on the character type.
    The problem is I have lots of GameObjects with different textures which occupy memory space.
    Is there a way to make such GameObjects not load memory into memory with Textures?

    Please refer to the screenshot below.

    Thanks in advance


    upload_2020-1-19_16-29-47.png
     

    Attached Files:

  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    As soon as you include it in the scene it gets loaded with the scene, no matter what, as a reference in a field or in the scene itself.

    If you separate them all out into individual prefabs for the different character types, and put them in the Resources folder. You can load in the chosen one at run time using Resources.Load.