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

Referenced prefabs and memory usage. Is there a better way?

Discussion in 'Editor & General Support' started by guavaman, Sep 9, 2011.

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    My game requires that most object be instanced from prefabs during gameplay (like most games do). I structured my setup like this:

    dataObject : GameObject - exists in the scene with Prefabs script attached.
    Prefabs script -- contains many arrays (GameObject) filled with links to every prefab in the game.
    When an object needs to be instantiated, it calls objectmanager.Instantiate(listId, objId) which looks up the desired ID from the desired list and instantiates it.

    So what I have seen from tests is that all the game objects in the lists, even if they are not instanced in the world, are loaded on scene load. (1GB memory usage). This is not ideal, however I can't think of another way to handle this. If I create individual dataObjects for each scene with only the prefabs actually needed for the scene listed, this would alleviate the memory problem, but it is somewhat of a data management nightmare with thousands of objects.

    For music I have the same problem. If I link the audio files to the in-scene prefab, I will be loading all the music in the game into memory, which is not what I want. I was planning to use Resources.Load, but I found a post here which says "2) Everything in your Resources folder is loaded at run time and not on demand. It doesn't actually stream it in or block to load the file."

    This would be especially bad for dialog sound files if it's loaded into memory at runtime.

    Update: For those stumbling upon this thread... The easiest solution seems to be using Resources.Load. It does indeed only load objects into memory when called. Also, use Resources.UnloadUnusedAssets() when necessary to unload unused objects from memory.
     
    Last edited: Oct 3, 2011
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    the 57 hour bump...
     
    XCO and blox5000 like this.
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Bump. Surely this is a common problem for bigger games...
     
    XCO and idurvesh like this.
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    There needs to be more resource available for code architecture design.
     
    XCO likes this.
  5. justinlloyd

    justinlloyd

    Joined:
    Aug 5, 2010
    Posts:
    1,680
    It is difficult to tell where you are spending your RAM given the lack of detail in your post. "OMG! Thousands of objects in scene take up 1GB of RAM!" What is your profiler showing, perhaps you just have a really bad data structure for managing your prefab and object references.
     
    blox5000 likes this.
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Excuse me. Nowhere was I complaining about the amount of RAM Unity is using. I know EXACTLY where my memory is going. I am not asking for help in determining where my memory is going. I am asking for guidance on best practices FOR MANAGING a large data structure. (Large lists of prefabs which can potentially be spawned in a scene, but are not yet spawned load at run time and use up a lot of memory. I'm looking for ideas on how to manage said large lists of prefabs and load only the ones into memory that I need in the current scene without resorting to creating separate, manually created data lists for each individual scene/level.) I am specifically speaking in generic terms because this is an architecture question. Anyone who is going to make something more complex than an iPhone poker game is going to have to deal with prefab data management in some way.

    Please read my post before responding next time. I'll wait for more helpful answers from others thanks.
     
    Last edited: Sep 20, 2011
  7. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    320
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Thanks for the link, but I don't think this really applies to my situation. I am aware of instance pooling and have considered implementing it for bullets and such in the past but have found performance acceptable for the moment with the normal instance/destroy paradigm.

    I guess I'm just really looking to learn how other people manage the issue of accessing prefabs for script-driven instantiation. I would guess MOST Unity users just make direct links to variables in the Inspector for prefabs they want instanced. (For example, you Gun shoots bulletPrefab. Most users probably just link up bulletPrefab in the Inspector directly in the Gun prefab.) This is great for most simple things but isn't very flexible especially when dealing with hundreds of prefabs, and is really a nightmare should you need to change something globally. (For example, suddenly you want all 300 different enemies that spawn bulletPrefab to start spawing bullet2Prefab instead.) Also, the prefab lists are extremely important to recording and then respawning prefabs when loading a saved game. (Read saved game binary, look up listId and indexId, instance, repopulate variables, done.)

    My method (described in post #1) allows me to use a more centralized approach where I spawn things with a arrayId + indexId. (Spawn bullet from array 1, index 12.) I do this for every type of prefab that may need to be spawned in-game. (Enemies, bullets, explosions, impact effects, trigger volumes, music, etc.) This works out great for the most part.

    The main problem I'm having is related to the pre-loading of these objects. My lists contain thousands of prefabs -- all the prefabs in the entire game are contained in these lists. What this means is that ALL the prefabs in the entire game are loaded on start and reside in memory because they're all linked in my dataObject (in-scene instance which holds the arrays).

    Possible solution #1:
    Bake out a separate dataObject for each level which contains only references to objects used on that level (or objects which can be potentially spawned by scripting on level). Cons: Quite complicated to manage manually. Making changes to the level such as adding a new enemy or object require this dataObject be updated as well.

    Possible solution #2:
    Force prefabs to load on-demand when instanced in scene. Not sure if this is even possible as Unity auto-loads all prefabs referenced by objects in the scene. I cannot find any way of saving prefab references without using links on a script attached to a GameObject in-scene. (One of the Editor classes has a command do access them by path, but it doesn't work in-game). Cons: Hiccups on load (may be acceptable). Ambiguous level memory footprint. May also require some kind of common object preloader (similar to preloading image in web development).
     
    Last edited: Sep 21, 2011
    XCO and idurvesh like this.
  9. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    320
    Just out of curiosity what are you doing that requires 1000's of prefabs?
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    A very big and complex game. :)
     
    Zinov likes this.
  11. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    I use the Resources folder and dynamically load in prefabs if they are not already referenced when I need them. Eg,

    Is the prefab reference == null ? Yup, so load in the prefab from resources folder then instantiate it. If its not null, just instantiate it.

    Works great for me, but I don't have 1000's of referenced prefabs... just 20-30.
     
  12. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    Hi, someone already mentioned PoolManager. I should add that it can be used entirely through scripting. One of the reasons I made sure of this is because we needed the flexibility in our own game. If you set it up through code, you could change your bullet prefab and it would propagate. I also recall seeing a dynamic database plugin and the creator had it working with PoolManager as well. This should create a pretty nice layer to work from.

    PoolManager2 introduced the ability to add pools at any time. So you could have pools in each level and let them unload and pre-load automatically. You could also have some which do not get destroyed on load of a new scene, so you could use a combination of the two.

    Another thing I am doing in our game is to create a static library and drop my prefabs in there, then access them by name to spawn via PoolManager. However, this isn't really necessary now that PoolManager SpawnPools can be used the same way. If you drag and drop a prefab (or add it via script), you can then access it by name via a dictionary from anywhere, which is extremely fast.

    Think of PoolManager as a framework for managing instances, not just "pooling". If you think it is 'almost' what you want. I'd be happy to talk about ways it could be better. Some of the main features in PoolManager2 came from the community.
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Interesting idea, but the reason I didn't pursue the Resources route was a quote I linked in my first post that says "2) Everything in your Resources folder is loaded at run time and not on demand. It doesn't actually stream it in or block to load the file."

    Have you done any memory tests with your system? The more I think about it, the more I'm inclined to believe this quote is wrong. It doesn't make a lot of sense to even have Resources.Load and Resources.UnloadUnusedAssets if everything is loaded at run time... This may be the best option I've heard so far if indeed the Resources folder does not load at runtime. I will do some tests.

    Thanks for your reply! I think I need to dig into it more to understand if pool manager might work for what I'm trying to do. It looks like you have a pretty nice system there. But I don't see how it would enable me to reduce my memory footprint or dynamically load objects or reduce the manual labor involved in configuring prefab lists on a per-level basis. I suppose if I created custom "pools" for each level that only contained the prefabs I needed on that level, that would work (and reduce memory), but doesn't seem a whole lot different than if I were to just create a custom GameObject per level with only the prefabs referenced in arrays that I need for the current level. Both methods seem to require a lot of manual labor defining every single prefab I may possibly spawn on the current level. Am I missing something about PM2 that might make this task easier?

    You mention creating a static library. How is this implemented? You're probably doing the same thing I am, but I'm not quite sure. I have a game object w/ a script attached which contains a bunch of GameObject arrays which are then filled by drag-and-dropping prefabs into the arrays in the inspector. Is this what you're doing? Because this is where I'm running into the memory issue -- everything that is linked loads at run time. I know of no other way to store references to prefabs except through serialized variables in the inspector. If you know another way, I'd love to hear it.
     
    Last edited: Sep 21, 2011
  14. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Poolmanager. I think loading them and instantiating them is still the best bet vs dynamic loading. Have you benchmarked how much ram it all takes?
     
  15. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    The whole point of the resources folder is that its available to load items at will during runtime, not preloaded at the start like a script reference to a prefab would be.

    I think the confusion here is with Webplayers, in that the entire resources folder gets downloaded as part of the first level being loaded, as they have to be available so any code can access them. SO in this save they are not pre-loaded into memory, but will increase your initial download times on a web player.
     
  16. flgBill

    flgBill

    Joined:
    Jul 12, 2011
    Posts:
    8
    Guavaman: thanks for pointing this out. I'm glad it's not just me who was seeing this happen.

    The solution is to use Resources.Load. The Unity Answers thread you linked to is probably referring to a different kind of dynamic resource loading. In my experience, prefabs and textures loaded via Resources.Load are not loaded into memory until then.

    (Relatedly, see Resources.UnloadUnusedAssets to prevent these resources from staying in memory after the scene changes.)



    To all: it seems like a few people didn't understand what Guavaman was experiencing, so here's a simplified example that affected us on the iPad.

    - We have a Playing Field object in our scene.
    - This Playing Field object has references to multiple Zone Data prefabs.
    - Each Zone Data prefab has references to multiple Background prefabs.
    - Each Background prefab contains a large background texture.

    Ultimately, the Playing Field only wants to instantiate and display a single Background. However, when this scene loads and tries to start, ALL of the background textures for ALL of the zones are loaded into memory! The game actually dies on the iPad before the scene can awaken, let alone instantiate any prefabs.

    In response, we've changed our scripts so that each Zone Data no longer references the Background prefabs directly. Instead, these prefabs are loaded via Resources.Load as needed.



    By the way, I noticed there is no page for optimizing memory usage on iOS yet, but if one is created then it should definitely advise people to use Resources.Load to load large, memory-consuming prefabs instead of referencing them directly.
     
    Last edited: Sep 21, 2011
    idurvesh likes this.
  17. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    First, about the static lists. .. Yes... but don't do it for the reason you posted. You have to manage it well when creating static references in this way and it doesn't address your needs because it means a drag and drop for everything. I never really liked it and only used it as a workaround for a specific issue. So ignore this.

    It won't. Pooling is all about performance and reuse. The idea is to move the performance intense stuff from when a player is interacting with the game to a time when interaction isn't as intense. Tthis doesn't necessary mean a loading screen, it could just mean doing stuff when there is less stuff going on - it doesn't have to be the beginning of the game though either, it could be any time.


    I guess it depends on what you mean by dynamically load objects. PoolManager can preload (or not) anything you want. By "preload" I mean it can make instances when you add a SpawnPool to the scene, either by having it in there already and loading the scene, or by adding it in yourself anytime. These instances start out despawned, so they load all the references in to memorry when loaded (the first one should be the most intense as far as this loading goes), but don't affect performance until you spawn it and they "activate". You can store SpawnPools in prefabs and load them anytime, so that is quite dynamic/flexible.

    A SpawnPool is intended to be used for an archtype of prefabs, such as "enemies", or whatever. All you have to do to make one is grab an empty game object and add the component, this makes it accessable from code via the Pools[] dict. You can do this part through scripting too of course. Adding prefabs can be done through scripting too, so no drag and drop. Just make a new PrefabPool with whatever options you need and pass it to PoolManager to be precessed and added. There are docs and examples for an entirely scripted solution.

    By the way, if you don't need any of the more advanced options, such as preloading, PoolManager will automatically create a PrefabPool the first time you use Spawn(). So you don't actually have to do any prefab setup at all unless you need to.


    For one, You don't have to do any of it yourself ;) and you get all the features, such as the fact it will clean-up after itself if you destroy the SpawnPool or load a new level, nice naming, preloading, culling (it can remove instances by destroying them over time to help re-claim some memory during gameplay, though this is counter to the point of pooling and should only be done if memory is an issue. There is much more about this in the docs.) You also don't get the PoolManager API for scripting all of this, so in this case you would have to roll the code AND drag and drop - or roll the code to avoid drag and drop. (I don't mean to make this sound like a hard sale. We don't need the $22 that bad! I'm sincerely trying to help, which is why i offered a refund if PoolManager doesn't help when all is said and done.)


    I would need to know what you mean by "manual labor defining..." to answer this. There can be more than one layer of dynamic interaction. I mentioned above I have seen a database system put in place over PoolManager to add another layer of flexibility. I think the PoolManager API makes any sort of instance management easier and we can always add to it if anyone finds a missing feature. I've added at least 3 useful items to the API for users in the latest version, including easy static access to prefabs once added/used.


    FWIW: I have read that loading a big textures can't be unloaded unless you do it yourself from Resources.Load(). I assume audio is the same. I don't know from first-hand experience though.
     
  18. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    I just want to point out that pooling is not a replacement for, or alternate to, resources.load, as others have pointed out. Both methods support different needs and workflows and could be used together. The two concepts are not directly related.

    ...hows that for a vague disclaimer?! :D
     
    Zinov likes this.
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Wow! This thread was looking like a dead end. Thanks to everyone for your valuable input!

    Ahh, I see! That does make a lot more sense. Loading as in DOWN-loading... I'm not doing a webplayer game so that's not an issue for me. Excellent! (Immitating Mr. Burns)

    Thank you! I'm glad as well to know I'm not alone. I imagine anyone making a game even remotely resembling the scale of a modern PC/console games would run into the issue.

    Great! Thanks for confirming this is the right direction to go in. I will start pursuing it and rework my system. (I'll probably do some common object preloading and leave the rest to load at spawn-time). Can't wait to see my memory footprint to drop

    Yes, that's what I was thinking so I was a bit confused about all the suggestions to use PM with regards to my problem. Thanks a million for your detailed response! It was very helpful.

    I did spend a some time watching your videos and reading some of the documentation to see if there was anything I was missing with regards to my understanding of PM2. It looks like a great system and I'll definitely revisit it when I get to the performance optimization of my game.

    Ain't it great, we've got 3 different versions of "load" being used in this thread:

    Load #1: Loading data from disk into RAM. Ex: Prefab placed in scene loads from disk into RAM at runtime.
    Load #2: Loading data from a webserver to the local drive (downloading) as used in the linked page.
    Load #3: Pre-instancing an object. PoolManager's use of "pre-load" (a little confusing since you are actually loading the data into RAM at the time the spawn pool is created/loaded).

    In this case, I was referring to not loading prefabs into memory until actually instanced in the scene.

    I am curious how you would add prefabs via scripting only if you don't already have a reference to the prefab somewhere (made by either drag-and-drop or Resources.Load I guess). Sorry if this is in the docs. I didn't see it referenced.

    That's what we call dedication! Hehe! Last I looked it was $29.95 on the site. Refund? I didn't see that you mentioned that. That's very nice of you.

    Since I think Resources.Load is more along the lines of my needs for this current problem, I probably won't have the time at the moment to work on implementing PM and will save that for a later pass. (I expect it might take some effort to get PM plugged intp my game as I do quite a lot of management in various ways already and it may conflict OOB).

    I'm assuming Resources.UnloadUnusedAssets would handle that... by "do it yourself" do you mean actually load it in via Resources.Load in the first place? (Because I can also read that as "textures can't be unloaded unless you unload it yourself from Resources.Load()" [assuming you mean UnloadUnusedAssets]

    Thanks for everyone's help. I think I'm on the right path now.
     
    Last edited: Sep 22, 2011
  20. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Loading a why not load AssetBundle withe the prefab if needed?
    One asset bundle per Prefab is a lot if you are using over 1000 prefabs.
    Maybe grouping like 10 or 100 prefabs per Asset Bundle.
     
  21. Rafes

    Rafes

    Joined:
    Jun 2, 2011
    Posts:
    764
    This is a very interesting topic and really tests the flexibility of the design/thinking all-around.

    Right. You caught me with a chicken-or-the-egg situation here. Sorry, lol. It should have occurred to me as I was helping a user with this the other day. Yes, you would load a reference first. This is a reference to the prefab, so you still need to manage the instanciation. This is where PoolManager would get 'plugged in'. You would use the prefab you load to build a prefab pool in some sort of loader script.

    I think you would do something like the following (the resources load line is pseudo code). Keep in mind that while there is a lot of flexibility and code access in PoolManager, to add it to a project you really only need to swap Instantiate() and Destroy() with Spawn() and despawn(). The rest is "gravy", as "they" say.
    PHP:
    // Create the pool 
    //    This will genreate a GameObject with a SpawnPool component
    string poolName "SomeName"  // Could name based on something dynamic
    PoolManager.Pools.CreatePool(poolName);

    // ...maybe a for loop?...

    // Get the prefab
    Transform prefab Resources.Load(...).transform   // Might need to cast

    // Create a prefab pool.
    var prefabPool = new PrefabPool(prefab);      
    prefabPool.preloadAmount 1;  // There are more options; all are optional   
    PoolManager.Pools[poolName].CreatePrefabPool(prefabPool);           
    Then, from any script....
    PHP:
    // These names could be found via some dynamic look-up from the loading system
    string poolName = ...;
    string prefabName = ...;

    // Super fast lookup to grab a prefab reference by name
    Transform prefab   PoolManager.Pools[poolName].prefabs[prefabName];

    // Spawn an instance
    Transform instance PoolManager.Pools[poolName].Spawn(prefab);
    I mentioned there was a DB solution out there. I found the thread. He said he got it working with PoolManager. (Please note that I haven't used this so I don't know if it matches the need above):
    http://forum.unity3d.com/threads/91618-Dynamic-Asset-Management-System-%28Please-Give-feedback-or-request-features%29
     
    Last edited: Sep 22, 2011
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Thanks for the suggestion. Up until now I had not paid much attention to Asset Bundles as I was under the impression that they were primarily for web players. After reading the docs on them, using them may provide a framework for doing what I need, though it looks like it would involve quite a bit of bundle contents planning (assuming per-level bundles). I'll do some more digging and experiment with them a bit and see if they might be a part of the solution.

    Thanks!
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    I'm glad, I was thinking I had missed something very basic about prefabs. Thanks for the examples and the link to the DB thread as well! I do appreciate you taking the time to explain things. I'll get busy figuring out how Resources.Load and AssetBundles may help my situation, then look into PM2 and the database system.
     
  24. hima

    hima

    Joined:
    Oct 1, 2010
    Posts:
    183
    Thank you for making this thread! I'm having this problem as well.

    So it seems like there is no other way but using Resource.Load... I was saving that as a last resource since I don't want to rearrange all the folders again but I guess there is no other choice :/
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    You're welcome! And I agree. The Resources folder kind of undoes all the time I spent organizing my project folder so nicely. :( I still have yet to implement the suggestions here. When I do, I'll post back with any new findings or tips.
     
  26. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    @guavaman Thanks much for creating this thread and everyone else for their contribution...Your good old deeds paying us real gold....

    I am into similar situation ,to avoid doing drag and drop on each scene I am using scriptable objects which holds global reference to my weapons and other prefabs ,it also reduced my memory footprint though there are still lot of prefab references present which causing high memory problem with crash on mobile devices.So planning to touch resources.Loa().
     
    CarterG81 likes this.
  27. Zinov

    Zinov

    Joined:
    Jul 20, 2015
    Posts:
    38
    The problem with Resources folder approach is that you can't create Atlases out of your textures placed there. Which means that your prefabs won't be optimal as well.
     
  28. Astro75

    Astro75

    Joined:
    Dec 18, 2014
    Posts:
    47
    Is there any other way to solve this auto-load by reference problem?
    We can't use Resources folder because for different builds we use different prefabs and Resource folder gets automatically included all the time.
     
  29. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    233
    I made a small plugin that, although doesn't solve other issues since it still requires the Resources folder, lets you drag & drop assets from Resources into slots in the inspector just as "normal" assets, without making Unity load them in memory until asked to do so, and without having to manually keep track of name/path changes: https://forum.unity3d.com/threads/d...n-inspector-without-loading-in-memory.459094/
     
  30. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    233
    I have updated the plugin I talked about above to make it possible to have the original assets inside any folder, by using a "proxy" asset inside a Resources folder. I have tested it specifically with atlases, and it works fine. More information in https://forum.unity3d.com/threads/d...thout-automatically-loading-in-memory.459094/
     
  31. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    Old thread, but still helpful. Thanks for this thread guavaman. I hadn't realized loading references to all of my prefabs once the game started included loading all my textures (3GB to RAM). When I realized this, I wanted to make sure Resources.Load was the right solution to load only the ones I needed.

    I thought I recognized you from another thread, but I forgot where. Then I saw REWIRED in your sig - ha! One of the best assets in the store.
     
    XCO and guavaman like this.
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,508
    Thanks! I'm glad you like Rewired.

    FYI Unity recommends that you do not use Resources for much of anything. Instead, they say to use Asset Bundles.

    https://unity3d.com/learn/tutorials/temas/best-practices/resources-folder

    2.1. Best Practices for the Resources System
    Don't use it.
     
  33. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    @XCO

    I know Unity says best practice is AssetBundles, and I guess theyre right, but they were a PITA to setup and maintain, and the entire process seems very contrarian to the reason we use Unity (to let Unity do things for us). Not to mention hideous build times.

    For simpler games, Resources.Load is best practice IMO. AssetBundles being best practice, maybe for big projects and niche circumstances (streaming).

    AssetBundles are still in beta/testing too. Managers & build tabs are on github, rather than part of the Editor. Although they claim it is also because theyre making Unity more modular.

    Still... that part of the doc is subjective. I made the mistake of assuming Unity's suggestions for Best Practice was always actual Best Practice. Definitely not the case here.
     
  34. chriszul

    chriszul

    Joined:
    Feb 13, 2018
    Posts:
    33
    There was some terrible bugs in their asset bundle manager asset so Unity pulled it from the asset store. It's still available in other projects and it can do this kind of thing really well, but it is harder to get it working than resources loading.

    I would say the key use of asset bundles is if you want to stream lots of content from a server and keep your app installer sizes down it will work for you if you get used to it. If you just want to load things dynamically to keep memory usage down and you have a static set of textures that you are happy with dropping into a resources folder, then that is the simplest option for you.
     
    Trisibo and CarterG81 like this.
  35. RobertVerdes

    RobertVerdes

    Joined:
    Nov 27, 2015
    Posts:
    6
  36. sajjadgameactor

    sajjadgameactor

    Joined:
    May 27, 2015
    Posts:
    8
    For all those who may face this problem. Unity Addressable Asset System, introduced in 2019, is the best current solution. You can store "Asset references" in an object, there is no need to be in the Resource folder and in addition Assets can be uploaded online on server.

    https://docs.unity3d.com/Packages/com.unity.addressables@0.3/manual/index.html

    This Migration guide can be very helpful to understand how it works
    https://docs.unity3d.com/Packages/c...3/manual/AddressableAssetsMigrationGuide.html
     
    Last edited: Mar 5, 2021
    SisusCo likes this.
  37. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,064
    Nah, it's designed to be async, it complicates my workflow, it's not the best solution. As long as you don't over rely on it, Resources folder is still fine.

    Plus Addressables got out of preview less than 2 years ago, which means they are very much still in preview.
     
    guavaman likes this.