A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.unity3d.com/Manual/LoadingResourcesatRuntime.html below:

Manual: Introduction to the Resources system

Use the Resources system to load assets at runtime

Load and unload assets with the Resources system

Introduction to the Resources system

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.

Using the Resources system

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.

Impact of large asset sets on the Resources system

It’s best practice to avoid putting a lot of content into the Resources system for the following reasons:

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.

Additional resources

Use the Resources system to load assets at runtime

Load and unload assets with the Resources system


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4