Search Unity

Resource Load

Discussion in 'Scripting' started by browne11, Jan 30, 2019.

  1. browne11

    browne11

    Joined:
    Apr 30, 2015
    Posts:
    138
    So I've been trying o remove resource.load from my game and go full scriptable objects. Right now I have about 300 abilities and they're loading from resource folders when asked. With scriptable objects however, I still don't see how I'm able to load them other then loading all 300 and storing them in a list. Which from my understanding is as resource intensive as just using resource load. Currently all of my data such as delays, damage etc are stored in XML and imported at the start and read when a new ability is acquired by a simple reference. But the stuff that is in the resource folder is just prefabs with particle effects which is what I need to load when called. When an ability is fired it grabs from the folder by name and instantiates it. Values are piped into the prefab and everything looks great.

    I'm unable to really find the proper route I should go with my design as scriptable objects aren't really going to help my prefab situation but simply allow me to remove the XML route.

    Perhaps I'm looking at this the wrong way or I need to redo entirely how my abilities work.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    There's nothing wrong with using Resources.Load(). It helps simplify a broad range of asset management problems.

    The main thing to note is that every asset located underneath a Resources directory gets included in the build, making the distribution size large, even if you're not using it.

    Remember also if you load all 300 scriptable object items, then every asset those assets point to is ALSO loaded at that moment, whether you go to use it or not.

    Easily the best combination of asset management approaches in Unity is to break things into individual scenes (or partial scenes) and put everything related to each scene in a folder. This scales to any arbitrarily large number of levels, plays VERY nicely with the Unity Asset Bundle system, and best of all once you unload a scene, generally everything that was consuming RAM goes away and you have a fresh slate.
     
    browne11 likes this.
  3. browne11

    browne11

    Joined:
    Apr 30, 2015
    Posts:
    138
    Thanks for the reply.

    I've gone down this road a few times now and I ended up keeping the resource route as I do need those objects in any scene. So what you're saying either approach makes no difference if I need them in all scenes. If so I've spun myself in a circle again on this. :p I'm just so thrown back on the unity resource.load page which says not to use it in a finished game.
     
    Last edited: Jan 31, 2019