Search Unity

I need opinions on placing audio/other items in resources folder

Discussion in 'Scripting' started by Unlimited_Energy, Oct 22, 2017.

  1. Unlimited_Energy

    Unlimited_Energy

    Joined:
    Jul 10, 2014
    Posts:
    469
    I am trying to see if I should put my short audio clips int eh resources folder. I have tried to search online but there are many ways to call audio. I have an Listof audio clips that need to get randomly selected from and Upon searching I found people saying to place them in the resource folder and using resource.load. Is this the standard, to place audio in the resource folder and should I always use resource.load to call those items? What else benefits from being placed in that folder?

    I want to make sure this is not some outdated method from an erlier version of unity and that this is something people still do in the resources folder.
     
    Violet-n-red likes this.
  2. Deleted User

    Deleted User

    Guest

    Honestly I think the benefit it that you can do most of everything using script rather than dragging and dropping in the inspector. I prefer to do most of my asset management with the Resources.Load() method. Especially if you are loading into a list or an array. Much more dynamic and flexible.
     
    Unlimited_Energy likes this.
  3. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    a better option to resources is AssetBundles, way more flexible.
     
    Last edited: Oct 23, 2017
  4. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    AssetBundles are definitely the way to go. Using the resources folder means the assets are always included in builds, whether they're used or not, and it plays hell with resource management. Ideally you should only ever use the resources folder in small projects where optimization isn't in any way an issue, and for fast prototyping to be replaced with AssetBundles later.
     
    Unlimited_Energy likes this.
  5. Unlimited_Energy

    Unlimited_Energy

    Joined:
    Jul 10, 2014
    Posts:
    469
    so does a assetbundle get called like resource.load? I usually create folders within the main assets folder for individual pieces of my game, all gameObjects to do with weapons goes in weapons folder, all characters in a character folder, audio in audio folder. I assign references to game objects by draging them into place in the inspector or finding the gameobject by name or tag and grabing a reference to a component on them. What benefit do I get to create an "asset bundle" and how do i go about using it?
     
  6. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    Here's a set of articles on this topic. It's quite an involved subject and there's some required knowledge about how Unity handles things internally, so there's really no quick answer to your questions. Jason Booth made an excellent series of replies to the subject in this thread which give a good overview of how AssetBundles work.

    AssetBundles aren't quite trivial to implement, but the Manager (link to the repository for it in the articles there) simplifies things a lot. There are a lot of benefits, mostly having to do with memory management and performance- breaking up a game into a bunch of smaller pieces means you can download those pieces individually as needed, which allows for things like "play while the game downloads", small version updates that don't require redownloading the entire game, and AssetBundle variations allow swapping out higher res textures / higher poly models with smaller versions without any changes in references or complex systems for managing it. That concept can even be taken to particle systems and special effects, with different versions working better with different hardware setups, so that the poorly performing assets aren't downloaded and wasting space at all, let alone memory.
     
    Last edited: Oct 23, 2017
  7. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    I hate that Best Practices article on Resources. It's incredibly poorly written.
    Why? In what way? This statement is meaningless without more context.
    From Unity's perspective? Or is this a commentary on how team's work in relation to asset management? Again, explain how and why these things are true.
    But if you're not delivering different content across platforms then this isn't a concern. This should be a caveat of the system, not an indictment of it/reason not to use it at all.
    Again.....why?
    Ok. So really what this is saying is don't put everything in a Resources folder. Which...fine that's fair enough. So don't do that and if you're not developing for a mobile platform then this doesn't matter to you anyway. Frankly, our game boots up almost immediately.

    What this article really needs is a side-by-side comparison of several iterations of a project. One that uses Resources and one that uses AssetBundles. Show users why they should be using them from a memory and performance perspective. Don't just give me hand-wavy bullet points about how one system is better than the other and then say don't use this.

    Fractured State loads most game content out of Resources. We do this because the actual game data sits external of the built executable (so you can change unit stats etc without re-compiling the project). We're diligent about our asset management and make sure to remove things that are no longer used. We don't change content when the delivery platform changes. If we're patching something in there then it's always delivered as a larger game patch anyway; and I'm not in the patch delivery business. Steam does it better than I could so I let Steam do it.

    If you're doing cross-platform development or you want to be able to download new content easily then use AssetBundles because that's what they're designed for. If you're looking at thousands of assets then don't use Resources. If none of this applies to you then use what works. Ultimately, you should be asking more questions about what kind of project you're making. In either case, someone on Unity's documentation team needs to re-write that article..