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. Dismiss Notice

Load Scriptable Objects

Discussion in 'Editor & General Support' started by compy14, May 12, 2021.

  1. compy14

    compy14

    Joined:
    Aug 9, 2015
    Posts:
    20
    Hello everyone, I have a question about the operation of scriptable objects. In my project I have a manager that manages all scriptable objects, and within that manager there are others that manage prefabs, gameobject, texture and other things. I have the problem that when I start the game, it loads everything referenced and memory use increases a lot. I have been doing testing and if the scriptable objects I have them in the resource folder when starting it does not load me as much. But I'm not sure about using the resources because everyone claims to be against it. Likewise, how do you see it? Basically I only want to load in memory the specific scriptable object when it is needed in memory, not when starting the app
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    Take a look at addressables. It will give you the ability to control what is loaded when you need it
     
  3. compy14

    compy14

    Joined:
    Aug 9, 2015
    Posts:
    20
    The problem is that the project in with in the 2017 version and i think in this adressable is experimental, any option? (avoid upgrade the version please)
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    Using asset bundles. It's a bit more involved than addressables.
    Or use Mono behaviours instead of ScriptableObjects, turn them into prefabs and put the prefabs into scenes which you can load additively when you need those parts.
    You could also use the streaming assets folder and load JSON files. It really depends on what these ScriptableObjects actually do and why they take up so much memory.
     
  5. compy14

    compy14

    Joined:
    Aug 9, 2015
    Posts:
    20
    I already use asset bundle for textures and images, but meshes and animations can't get it to work and that's why I was looking at an alternative. Thanks for the answers
     
    karl_jones likes this.
  6. compy14

    compy14

    Joined:
    Aug 9, 2015
    Posts:
    20
    Basically I was asking for your help because I am optimizing someone else's code. And now I load the scriptable with asset bundle, and it works much better. But a problem arises, and I have seen that my partner did not use the unloads with the assetbundle, and I have started to do them. And with apk on android it works perfect but when you make version aab and upload it to the google store, then when it unloads it no longer lets you access the asset bundle again. What do you think it could be? When you do unload, what does it do exactly? (the documentation I have seen is somewhat sparse and does not specify much)