The Resources system provides a simple way of managing assets in memory. To use the Resources system, you create a folder called Resources in your project and add assets to it. During the build process, Unity finds the assets in the Resources folder and bundles them into a serialized file with metadata and indexing information. You can then use the Resources API to load and unload the assets in your application.
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 Addressables package provides a better way of managing complex sets of assets.
It’s an ideal system for prototyping, or for smaller projects which need assets throughout the lifetime of the application.
The Resources system has the following limitations:
Resources folders are always included in the Player build, even if they’re not referenced by anything. This can lead to large build sizes.Resources.Load remain in memory until explicitly unloaded with Resources.UnloadUnusedAssets, which unloads all unused assets loaded by Resources, or until the 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 infoResources folder, then building and starting your application can take a long time.Resources.Load returns null and becomes a runtime error, so you need to manually track which assets are needed.The Resources system can be helpful in the following situations:
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.If you need to manage content via a CDN, or do regular patch updates, then AssetBundles and the Addressables package are the recommended alternative. You can also use direct references if you don’t need the extra control that the Resources system provides.
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.