The Resources
class allows you to find and access objects that are in Resources
folders in your project.
You can use the Resources system to make an asset available to a project without loading it in as part of a sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary. When you add content to a folder named Resources
in your project, Unity makes it available to load when needed, independent of the scenes that you build.
However, having the content constantly available at runtime has a significant performance impact on your project, especially if it contains a large amount of assets. The AssetBundles system, or the Addressables package provide a better way of managing complex sets of assets. For more information on the different asset management options, refer to Introduction to asset management.
The Resources
system can be helpful in the following situations:
Resources
folder when a project moves into full production.Examples of the latter include MonoBehaviour singletons used to host prefabsAn asset type that allows you to store a GameObject complete with components and properties. The prefab acts as a template from which you can create new object instances in the scene. More info
See in Glossary, or ScriptableObject instances containing third-party configuration data, such as a Facebook App ID.
It’s best practice to avoid putting a lot of content into the Resources system for the following reasons:
Resources
folder slows down application startup and the length of builds.Resources
system makes it harder to deliver custom content to specific platforms and prevents incremental content upgrades.Resources
folder requires a player rebuild and redeployment, whereas AssetBundles are better suited for incremental content updates.AssetBundles and the Addressables package are the recommended alternative.
Unity combines all objects referenced from assets in the Resources
folder into a single serialized file when you build a project, similar to building one large AssetBundle. Unity takes time to construct the data structures that index all the objects in the file, and uses memory proportional to the number of objects, even if they aren’t loaded. This has an impact on performance if the number of individual assets in Resource folders are large, or if there are prefabs that contain a lot of objects. For example, initializing a Resources system containing 10 thousand assets takes several seconds on low-end mobile devices, even though most of the objects contained in Resources folders are rarely needed in an application’s first scene.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.