Unity Development — The Resources Folder

It is completely fine (and maybe beneficial) to avoid using the Resources folder in Unity, but it has its good points too.

Today’s Objective: Show how you can load game assets from the Resources project folder at runtime, and the benefits that gives.

Note: I haven’t used the Resources folder a lot, so at this point I am no where near an expert on its use. This post is meant as a brief introduction to the possibility of its use, and you should research it further before implementing it in a project.

What is the Resources folder in Unity?

The “Resources” folder is a special folder within the project files of a Unity project. The folder is not there by default, but can be created simply by creating a new folder inside the “Assets” folder and naming it “Resources” (The name is the important part).

The Assets and Objects in all folders named “Resources” are combined into a single serialized file when a project is built. This file also contains metadata and indexing information, similar to an AssetBundle.

[The Resources folder is…] the system that allows developers to store Assets within one or more folders named Resources and to load or unload Objects from those Assets at runtime using the Resources API. — Unity Source

The Code:

A more in-depth implementation could be like this:

Best Practices for the Resources System:

[Quoted from Unity Source]

Don’t use it.

This strong recommendation is made for several reasons:

  • Use of the Resources folder makes fine-grained memory management more difficult.
  • Improper use of Resources folders will increase application startup time and the length of builds.
  • As the number of Resources folders increases, management of the Assets within those folders becomes very difficult
  • The Resources system degrades a project’s ability to deliver custom content to specific platforms and eliminates the possibility of incremental content upgrades.
  • AssetBundle Variants are Unity’s primary tool for adjusting content on a per-device basis.

Proper uses of the Resources system:

[Quoted from Unity Source]

There are two specific use cases where the Resources system can be helpful without impeding good development practices:

  1. The ease of the Resources folder makes it an excellent system to rapidly prototype. However, when a project moves into full production, the use of the Resources folder should be eliminated.
  2. The Resources folder may be useful in some trivial cases, if the content is:
  • Generally required throughout a project’s lifetime,
  • Not memory-intensive,
  • Not prone to patching, or does not vary across platforms or devices,
  • Or used for minimal bootstrapping.

Final notes:

This is only a brief intro into the use of the Resources folder, and I have not covered many parts/factors of its use. If you wish to learn more, please do more of your own research to determine if the Resources folder is suitable for your project/s.

Best of luck to you!

--

--

--

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Mining the Rarest Element in Projects: A Good Idea

My Journey to 3D Printing: Chapter IV

C++ PROGRAM TO PRINT ALPHABET TRIANGLE!!!

Using Percy to add visual testing to a Jekyll site

A NEW PATH: MY ANDROID LEARNING COMMUNITY EXPERIENCE

Introducing TyeHub: A new way to model data in the API world

CS373 Spring 2021: Blog 2

Full tour of App Maker’s interface

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vincent Taylor

Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

Create A Loading Scene In Unity

47 High Quality Plugins on Unity Asset Store-Essential Tools for Unity Developers

Quick tip — How to set up Occlusion Culling in Unity

Mastering Unity Scripting | Summary — Chapter 1: Unity C# Refresher