What use instead of Resources folder?
The following code allows me to simply add new audio files to my resources folder and rebuild - I don't have to change the code or "drag and drop" files in the inspector (that I especially hate).
public AudioClip[] playlist;
private void Awake()
{
playlist = Resources.LoadAll("Music/MusicForrest") as AudioClip[];
}
I've been utilizing loading stuff from Resources folder (audio files, textures, etc.) for some time. But now I'm reading the Best Practices for the Resources System page about Resources folder and the first advice from Unity guys is: "Don't use it."
The question is what should I use as an alternative to Resources folder while retaining the simplicity of adding new stuff (adio files, textures, etc.) to the game?
The Resource folder has special auto-load rules in Unity builds. Read the page which explains the rare times you need that folder - it also explains the normal way, which is to use any other folder (the last line of tashimo's answer, in more detail.)
Answer by ModLunar · Aug 24, 2017 at 08:17 PM
I was wondering exactly the same thing! I heard some things about making AssetBundles and being able to load lots of assets using those. From what I heard, AssetBundles are recommended by Unity for us to use, though I have little experience with them.
I also was thinking, if using AssetBundles doesn't do it (or perhaps you don't want to for some reason) maybe an editor script could set the references for you in the inspector if you have your assets organized under a folder? I'm kind of just thinking off the top of my head, but I hope some of this thinking out loud helps!
Answer by tanoshimi · Jan 07, 2017 at 11:18 AM
From the page you linked: "Resources is an excellent system during rapid prototyping and experimentation because it is simple and easy to use. However, when a project moves into full production, it is strongly recommended to eliminate uses of the Resources folder."
So if you're changing your music files a lot during development, that's fine to continue to use. But when your assets become fixed and you move into production, you should create instance references to them in an audiomanager object, say.
tanoshimi I know what the page reads, because I read it all. I want to avoid "dragging and dropping" stuff in inspector. That is why I asked my question in my post: what should I use as an alternative to Resources folder.
The alternative to loading assets from the Resources folder is to create references in the inspector. That's how Unity works.
Answer by tinglers · Mar 04, 2017 at 03:45 PM
maybe this is what you are looking for? https://unity3d.com/learn/tutorials/topics/scripting/assetbundles-and-assetbundle-manager
Your answer
Follow this Question
Related Questions
how to load texture from C:\ Folder at Runtime build 2 Answers
asset quality suddenly very low? 0 Answers
Warning:Trying to move asset to location it came from...[Please Help] 0 Answers
Asset Bundle vs Resources vs ?? 1 Answer
How does Addressable assets load from local works specialy for webgl? 0 Answers