Unity_Addressable_Loading Addressable assets(加载资源)
The Addressables class provides several methods for loading Addressable assets. You can load assets one at a time or in batches. To identify the assets to load, you pass either a single key or a list of keys to the loading function. A key can be one of the following objects:
译:Addressables类提供了几种用于加载Addressable资产的方法。您可以逐个加载资产或批量加载。要识别要加载的资产,可以将单个键或键列表传递给加载函数。键可以是以下对象之一:
Address: a string containing the address you assigned to the asset译:Address:包含您为资产分配的地址的字符串
Label: a string containing a label assigned to one or more assets译:Label:包含分配给一个或多个资产的标签的字符串
AssetReference object: an instance of AssetReference译:AssetReference对象:AssetReference的实例
IResourceLocation instance: an intermediate object that contains information to load an asset and its dependencies.译:IResourceLocation实例:包含加载资产及其依赖项信息的中间对象。
When you call one of the asset loading functions, the Addressables system begins an asynchronous operation that carries out the following tasks:
译:调用其中一个资产加载函数时,Addressables系统开始异步操作,执行以下任务:
Looks up the resource locations for the specified keys (except IResourceLocation keys)译:查找指定键的资源位置(除IResourceLocation键之外)
Gathers the list of dependencies译:收集依赖关系列表
Downloads any remote AssetBundles that are required译:下载所需的任何远程AssetBundle
Loads the AssetBundles into memory译: 将AssetBundle加载到内存中
Sets the Result object of the operation to the loaded objects译:将操作的Result对象设置为已加载的对象
Updates the Status of the operation and calls any Completed event listeners译:更新操作的状态并调用任何已完成的事件侦听器
If the load operation succeeds, the Status is set to Succeeded and the loaded object or objects can be accessed from the Result object.
译:如果加载操作成功,则状态设置为Succeeded,并且可以从Result对象访问已加载的对象或对象集合
If an error occurs, the exception is copied to the OperationException member of the operation object and the Status is set to Failed. By default, the exception is not thrown as part of the operation. However, you can assign a handler function to the ResourceManager.ExceptionHandler property to handle any exceptions. Additionally, you can enable the Log Runtime Exceptions option in your Addressable system settings to record errors to the Unity Console.
译:如果发生错误,则异常会复制到操作对象的OperationException成员中,并将状态设置为Failed。默认情况下,异常不作为操作的一部分抛出。但是,可以为ResourceManager.ExceptionHandler属性分配处理程序函数以处理任何异常。此外,您可以在Addressable系统设置中启用Log Runtime Exceptions选项,以将错误记录到Unity控制台中。
When you call loading functions that can load multiple Addressable assets, you can specify whether the entire operation should abort if any single load operation fails or whether the operation should load any assets it can. In both cases, the operation status is set to failed. (Set the releaseDependenciesOnFailure
parameter to true in the call to the loading function to abort the entire operation on any failure.)
译:当调用可以加载多个Addressable资产的加载函数时,可以指定整个操作是否应在任何单个加载操作失败时中止,或者操作是否应加载它可以加载的任何资产。在这两种情况下,操作状态都设置为失败。(在调用加载函数时将releaseDependenciesOnFailure参数设置为true可在任何失败时中止整个操作。)
See Operations for more information about asynchronous operations and writing asynchronous code in Unity scripts.
译:有关异步操作和在Unity脚本中编写异步代码的更多信息,请参见“操作”章节
Loading a single asset
Use the LoadAssetAsync method to load a single Addressable asset, typically with an address as the key:
译:使用LoadAssetAsync方法加载单个Addressable资产,通常使用地址作为键:
NOTE
You can use a label or other type of key when you call LoadAssetAsync, not just an address. However, if the key resolves to more than one asset, only the first asset found is loaded. For example, if you call this method with a label applied to several assets, Addressables returns whichever one of those assets that happens to be located first.
译:在调用LoadAssetAsync时,您可以使用标签或其他类型的键,而不仅仅是地址。但是,如果该键解析为多个资产,则只会加载找到的第一个资产。例如,如果您使用应用于多个资产的标签调用此方法,则Addressables会返回最先找到的那个资产
Loading multiple assets
Use the LoadAssetsAsync method to load more than one Addressable asset in a single operation. When using this function, you can specify a single key, such as a label, or a list of keys.
译:使用LoadAssetsAsync方法在单个操作中加载多个Addressable资产。使用此函数时,可以指定单个键,例如标签,或键列表
When you specify multiple keys, you can specify a merge mode to determine how the sets of assets matching each key are combined:
译:当您指定多个键时,可以指定合并模式以确定如何组合与每个键匹配的资产集
Union : include assets that match any key译:Union:包括匹配任何键的资产
Intersection : include assets that match every key译:Intersection:包括匹配每个键的资产
UseFirst: include assets only from the first key that resolves to a valid location译:UseFirst:仅包括从解析为有效位置的第一个键中的资产
You can specify how to handle loading errors with the releaseDependenciesOnFailure
parameter. If true, then the operation fails if it encounters an error loading any single asset. The operation and any assets that did successfully load are released.
译:您可以使用releaseDependenciesOnFailure参数指定如何处理加载错误。如果为true,则如果遇到任何单个资产加载错误,则操作失败。操作和任何成功加载的资产都将被释放
If false, then the operation loads any objects that it can and does not release the operation. In the case of failures, the operation still completes with a status of Failed. In addition, the list of assets returned has null values where the failed assets would otherwise appear.
译:如果为false,则操作会加载任何可以加载的对象,并且不会释放操作。在失败的情况下,操作仍将以失败状态完成。此外,返回的资产列表中的空值是失败的资产将出现的位置
Set releaseDependenciesOnFailure
to true when loading a group of assets that must be loaded as a set in order to be used. For example, if you are loading the assets for a game level, it might make sense to fail the operation as a whole rather than load only some of the required assets.
译:在加载必须作为一组加载的一组资产时,请将releaseDependenciesOnFailure设置为true。例如,如果您正在加载游戏级别的资产,则整个操作失败可能比仅加载某些所需资产更合理
Correlating loaded assets to their keys
When you load multiple assets in one operation, the order in which individual assets are loaded is not necessarily the same as the order of the keys in the list you pass to the loading function.
译:当您在一个操作中加载多个资产时,单个资产加载的顺序不一定与您传递给加载函数的密钥列表中的顺序相同
If you need to associate an asset in a combined operation with the key used to load it, you can perform the operation in two steps:
译:如果您需要将组合操作中的资产与用于加载它的键相关联,则可以分两步执行操作
Load the IResourceLocation instances with the list of asset keys.译:使用资产键列表加载IResourceLocation实例
Load the individual assets using their IResourceLocation instances as keys.译:使用它们的IResourceLocation实例作为键加载单个资产
The IResourceLocation object contains the key information so you can, for example, keep a dictionary to correlate the key to an asset. Note that when you call a loading function, such as LoadAssetsAsync, the operation first looks up the IResourceLocation instances that correspond to a key and then uses that to load the asset. When you load an asset using an IResourceLocation, the operation skips the first step. Thus, performing the operation in two steps does not add significant additional work.
译:IResourceLocation对象包含密钥信息,因此您可以例如保留字典以将密钥与资产相关联。请注意,当您调用加载函数(例如LoadAssetsAsync)时,操作首先查找与密钥对应的IResourceLocation实例,然后使用它来加载资产。当您使用IResourceLocation加载资产时,操作跳过第一步。因此,分两步执行操作不会增加显着的额外工作量
The following example loads the assets for a list of keys and inserts them into a dictionary by their address (PrimaryKey). The example first loads the resource locations for the specified keys. When that operation is complete, it loads the asset for each location, using the Completed event to insert the individual operation handles into the dictionary. The operation handles can be used to instantiate the assets, and, when the assets are no longer needed, to release them.
译:以下示例加载指定键的资产并将其按地址(PrimaryKey)插入字典中。示例首先加载指定键的资源位置。当该操作完成时,它会为每个位置加载资产,并使用Completed事件将单个操作句柄插入字典中。操作句柄可用于实例化资产,并在不再需要资产时释放它们
Note that the loading function creates a group operation with ResourceManager.CreateGenericGroupOperation. This allows the function to continue after all the loading operations have finished. In this case, the function dispatches a "Ready" event to notify other scripts that the loaded data can be used.
译:请注意,载入函数使用ResourceManager.CreateGenericGroupOperation创建了一个组操作。这使得函数在所有加载操作完成后继续执行。在这种情况下,函数会发送“Ready”事件以通知其他脚本可使用已加载的数据
Loading an AssetReference
The AssetReference class has its own load method, LoadAssetAsync.
译:AssetReference类有自己的load方法,LoadAssetAsync
You can also use the AssetReference object as a key to the Addressables.LoadAssetAsync methods. If you need to spawn multiple instances of the asset assigned to an AssetReference, use Addressables.LoadAssetAsync, which gives you an operation handle that you can use to release each instance.
译:您还可以将AssetReference对象用作Addressables.LoadAssetAsync方法的关键字。如果您需要生成分配给AssetReference的资产的多个实例,请使用Addressables.LoadAssetAsync,它会为您提供操作句柄,您可以使用该操作句柄释放每个实例
See AssetReference for more information about using AssetReferences.
译:有关使用AssetReferences的更多信息,请参见AssetReference
Loading Scenes
Use the Addressables.LoadSceneAsync method to load an Addressable Scene asset by address or other Addressable key object.
译:使用Addressables.LoadSceneAsync方法按地址或其他Addressable键对象加载Addressable场景资产
NOTE
Addressables.LoadSceneAsync uses the Unity Engine SceneManager.LoadSceneAsync method internally. API that affects the behaviour of SceneManager.LoadSceneAsync will most likely affect Addressables.LoadSceneAsync in the same way, for example Application.backgroundLoadingPriority.
译:Addressables.LoadSceneAsync在内部使用Unity Engine SceneManager.LoadSceneAsync方法。影响SceneManager.LoadSceneAsync行为的API很可能也会以同样的方式影响Addressables.LoadSceneAsync,例如Application.backgroundLoadingPriority
The remaining parameters of the method correspond to those used with the SceneManager.LoadSceneAsync method:
译:方法的其余参数对应于使用SceneManager.LoadSceneAsync方法使用的参数
loadMode: whether to add the loaded Scene into the current Scene or to unload and replace the current Scene.译:loadMode:是否将加载的场景添加到当前场景中,还是卸载并替换当前场景
loadSceneParameters: includes loadMode in addition to localPhysicsMode, used when loading the Scene to specify whether a 2D and/or 3D physics Scene should be created译:loadSceneParameters:包括loadMode以及localPhysicsMode,用于在加载场景时指定是否创建2D和/或3D物理场景
activateOnLoad: whether to activate the scene as soon as it finishes loading or to wait until you call the SceneInstance object's ActivateAsync method. Corresponds to the AsyncOperation.allowSceneActivation option. Defaults to true.译:activateOnLoad:是否在完成加载后立即激活场景,还是等待您调用SceneInstance对象的ActivateAsync方法。对应于AsyncOperation.allowSceneActivation选项。默认值为true
priority: the priority of the AsyncOperation used to load the Scene. Corresponds to the AsyncOperation.priority option. Defaults to 100.译:priority:用于加载场景的AsyncOperation的优先级。对应于AsyncOperation.priority选项。默认值为100
WARNING
Setting the activateOnLoad
parameter to false blocks the AsyncOperation queue, including the loading of any other Addressable assets, until you activate the scene. To activate the scene, call the ActivateAsync method of the SceneInstance returned by LoadSceneAsync. See AsyncOperation.allowSceneActivation for additional information.
译:注意:将activateOnLoad参数设置为false会阻塞AsyncOperation队列,包括加载其他Addressable资产,直到您激活场景。要激活场景,请调用LoadSceneAsync返回的SceneInstance的ActivateAsync方法。有关详细信息,请参见AsyncOperation.allowSceneActivation
The following example loads a scene additively. The Component that loads the Scene, stores the operation handle and uses it to unload and release the Scene when the parent GameObject is destroyed.
译:下面的示例会逐步加载场景。加载场景的组件会存储操作句柄,并在父GameObject销毁时使用它来卸载和释放场景。
See the Scene loading project in the Addressables-Sample repository for additional examples.
译:有关其他示例,请参见Addressables-Sample存储库中的场景加载项目
If you load a Scene with LoadSceneMode.Single, the Unity runtime unloads the current Scene and calls Resources.UnloadUnusedAssets. See Releasing Addressable assets for more information.
译:如果您使用LoadSceneMode.Single加载场景,则Unity运行时会卸载当前场景并调用Resources.UnloadUnusedAssets。有关详细信息,请参见发布Addressable资产
NOTE
In the Editor, you can always load scenes in the current project, even when they are packaged in a remote bundle that is not available and you set the Play Mode Script to Use Existing Build. The Editor loads the Scene using the asset database.
译:注意:在编辑器中,即使场景打包在不可用的远程包中,并将Play Mode Script设置为Use Existing Build,您仍然可以加载当前项目中的场景。编辑器使用资产数据库加载场景
Loading assets by location
When you load an Addressable asset by address, label, or AssetReference, the Addressables system first looks up the resource locations for the assets and uses these IResourceLocation instances to download the required AssetBundles and any dependencies. You can perform the asset load operation in two steps by first getting the IResourceLocation objects with LoadResourceLocationsAsync and then using those objects as keys to load or instantiate the assets.
译:当通过地址、标签或AssetReference加载Addressable资产时,Addressables系统首先查找资产的资源位置,并使用这些IResourceLocation实例下载所需的AssetBundle和任何依赖项。您可以通过首先使用LoadResourceLocationsAsync获取IResourceLocation对象,然后使用这些对象作为关键字来加载或实例化资产,执行资产加载操作的两个步骤
IResourceLocation objects contain the information needed to load one or more assets.
The LoadResourceLocationsAsync method never fails. If it cannot resolve the specified keys to the locations of any assets, it returns an empty list. You can restrict the types of asset locations returned by the function by specifying a specific type in the type
parameter.
The following example loads locations for all assets labeled with "knight" or "villager":
译:IResourceLocation对象包含加载一个或多个资产所需的信息。 LoadResourceLocationsAsync方法永远不会失败。如果无法将指定的键解析为任何资产的位置,则返回空列表。您可以通过在类型参数中指定特定类型来限制函数返回的资产位置类型。 以下示例加载所有标记为“knight”或“villager”的资产的位置
Loading locations of subobjects
Locations for SubObjects are generated at runtime to reduce the size of the content catalogs and improve runtime performance. When you call LoadResourceLocationsAsync with the key of an asset with subobjects and don't specify a type, then the function generates IResourceLocation instances for all of the subobjects as well as the main object (if applicable). Likewise, if you do not specify which subobject to use for an AssetReference that points to an asset with subobjects, then the system generates IResourceLocations for every subobject.
译:在运行时生成SubObjects的位置可以减小内容目录的大小并提高运行时性能。当您使用LoadResourceLocationsAsync调用具有SubObjects的资产的关键字并且未指定类型时,函数会为所有SubObjects以及主对象(如果适用)生成IResourceLocation实例。同样,如果您未指定AssetReference指向具有SubObjects的资产的子对象,则系统会为每个子对象生成IResourceLocations
For example, if you load the locations for an FBX asset, with the address, "myFBXObject", you might get locations for three assets: a GameObject, a Mesh, and a Material. If, instead, you specified the type in the address, "myFBXObject[Mesh]", you would only get the Mesh object. You can also specify the type using the type
parameter of the LoadResourceLocationsAsync function.
译:例如,如果您加载FBX资产的位置,地址为“myFBXObject”,则可以获得三个资产的位置:GameObject、Mesh和Material。如果您在地址中指定类型“myFBXObject [Mesh]”,则只会得到Mesh对象。您还可以使用LoadResourceLocationsAsync函数的类型参数指定类型
Instantiating objects from Addressables
You can load an asset, such as a Prefab, and then create an instance of it with Instantiate. You can also load and create an instance of an asset with Addressables.InstantiateAsync. The primary difference between these two ways of instantiating objects is how the asset reference counts are affected.
译:您可以加载资产(例如Prefab),然后使用Instantiate创建其实例。您也可以使用Addressables.InstantiateAsync加载并创建资产的实例。这两种实例化对象方式之间的主要区别在于如何影响资产引用计数
When you use InstantiateAsync, the reference counts of the loaded assets are incremented each time you call the method. Thus if you instantiate a Prefab five times, the reference count for the Prefab asset and any of its dependencies are incremented by five. You can then release each instance separately as they are destroyed in the game.
译:当您使用InstantiateAsync时,每次调用该方法时,加载的资产的引用计数都会增加。因此,如果您实例化Prefab五次,则Prefab资产及其所有依赖项的引用计数都会增加五次。然后,当游戏中的每个实例被销毁时,您可以单独释放每个实例
When you use LoadAssetAsync and Object.Instantiate, then the asset reference counts are only incremented once, for the initial load. If you release the loaded asset (or its operation handle) and the reference count drops to zero, then the asset is unloaded and all the additional instantiated copies lose their subassets as well -- they still exist as GameObjects in the scene, but without Meshes, Materials, or other assets that they depend on.
译:当您使用LoadAssetAsync和Object.Instantiate时,资产引用计数仅在初始加载时增加一次。如果您释放了加载的资产(或其操作句柄)并且引用计数降至零,则资产将被卸载,所有其他实例化的副本也会失去其子资产--它们仍然存在于场景中的GameObject,但没有Meshes,Materials或其他其依赖的资产
Which scenario is better, depends on how you organize your object code. For example, if you have a single manager object that supplies a pool of Prefab enemies to spawn into a game level, it might be most convenient to release them all at the completion of the level with a single operation handle stored in the manager class. In other situations, you might want to instantiate and release assets individually.
译:哪种场景更好,取决于您如何组织对象代码。例如,如果您有一个单独的管理对象,为游戏级别提供一组Prefab敌人池,则存储在管理类中的单个操作句柄在完成级别时最方便释放它们。在其他情况下,您可能需要单独实例化和释放资产
The following example calls InstantiateAsync to instantiate a Prefab. The example adds a component to the instantiated GameObject that releases the asset when the GameObject is destroyed.
译:以下示例调用InstantiateAsync以实例化Prefab。示例为实例化的GameObject添加了一个组件,该组件在销毁GameObject时释放资产
When you call InstantiateAsync you have the same options as the Object.Instantiate method, and also the following additional parameters:
译:当您调用InstantiateAsync时,您具有与Object.Instantiate方法相同的选项,以及以下附加参数:
instantiationParameters: this parameter takes a InstantiationParameters struct that you can use to specify the instantiation options instead of specifying them in every call to the InstantiateAsync call. This can be convenient if you use the same values for multiple instantiations.译:instantiationParameters:此参数采用InstantiationParameters结构,您可以使用该结构在每次调用InstantiateAsync时指定实例化选项。如果您对多个实例使用相同的值,则可以使用此选项
trackHandle: If true, which is the default, then the Addressables system keeps track of the operation handle for the instantiated instance. This allows you to release the asset with the Addressables.ReleaseInstance method. If false, then the operation handle is not tracked for you and you must store a reference to the handle returned by InstantiateAsync in order to release the instance when you destroy it.译:trackHandle:如果为true(默认值),则Addressables系统跟踪实例化实例的操作句柄。这允许您使用Addressables.ReleaseInstance方法释放资产。如果为false,则系统不会为您跟踪操作句柄,您必须存储由InstantiateAsync返回的句柄引用,以便在销毁实例时释放它
Asynchronous Loading
The Addressables system API is asynchronous and returns an AsyncOperationHandle for use with managing operation progress and completion. Addressables is designed to content location agnostic. The content may need to be downloaded first or use other methods that can take a long time. To force synchronous execution, See Synchronous Addressables for more information.
译:Addressables系统API是异步的,并返回AsyncOperationHandle以用于管理操作进度和完成。Addressables旨在内容位置无关。内容可能需要首先下载或使用其他需要很长时间的方法。有关强制同步执行的详细信息,请参见同步Addressables
When loading an asset for the first time, the handle is done after a minimum of one frame. You can wait until the load has completed using different methods as shown below. If the content has already been loaded, execution times may differ between the various asynchronous loading options shown below.
译:第一次加载资产时,句柄完成至少需要一帧的时间。您可以使用以下不同的方法等待加载完成。如果内容已经加载,则在下面显示的各种异步加载选项之间的执行时间可能会有所不同
Coroutine: Always be delayed at minimum of one frame before execution continues.译:协程:始终至少延迟一帧,然后才继续执行
Completed callback: Is a minimum of one frame if the content has not already been loaded, otherwise the callback is invoked in the same frame.译:完成回调:如果内容尚未加载,则至少需要一帧,否则在同一帧中调用回调
Awaiting AsyncOperationHandle.Task: Is a minimum of one frame if the content has not already been loaded, otherwise the execution continues in the same frame.译:等待AsyncOperationHandle.Task:如果内容尚未加载,则至少需要一帧,否则在同一帧中继续执行
Releasing Addressable assets
Because the Addressables system uses reference counting to determine whether an asset is in use, you must release every asset that you load or instantiate when you are done with it. See Memory Management for more information.
译:释放Addressable资产 由于Addressables系统使用引用计数来确定资产是否正在使用,因此在使用完每个加载或实例化的资产后,必须释放它。有关更多信息,请参见内存管理
When you unload a Scene, its AssetBundle is unloaded. This unloads assets associated with the Scene, for example any GameObjects moved from the original Scene to a different Scene.
译:当您卸载场景时,其AssetBundle也会被卸载。这将卸载与场景相关的资产,例如从原始场景移动到不同场景中的任何GameObject
Note that the Unity runtime automatically calls UnloadUnusedAssets
when you load a Scene using the LoadSceneMode.Single mode. To prevent the Scene and its assets from being unloaded, maintain a reference to the scene load operation handle until it the Scene should be unloaded manually. One way to do this is to use ResourceManager.Acquire on the load operation handle. Conventional methods of preserving the assets such as Object.DontDestroyOnLoad or HideFlags.DontUnloadUnusedAsset will not work.
译:请注意,当您使用LoadSceneMode.Single模式加载场景时,Unity运行时会自动调用UnloadUnusedAssets。为防止场景及其资产被卸载,请保留对场景加载操作句柄的引用,直到手动卸载场景。一种方法是在加载操作句柄上使用ResourceManager.Acquire。传统的保存资产的方法,如Object.DontDestroyOnLoad或HideFlags.DontUnloadUnusedAsset将无法工作。
Individual Addressables and their operation handles that you loaded separately from the Scene are not released. You must call Resources.UnloadUnusedAssets or UnloadAsset to free these assets. (The exception to this is that any Addressable assets that you instantiated using Addressables.InstantiateAsync with trackHandle
set to true, the default, are automatically released.)
译:单独从场景加载的Addressables及其操作句柄不会被释放。您必须调用Resources.UnloadUnusedAssets或UnloadAsset来释放这些资产。(例外情况是使用trackHandle设置为true的Addressables.InstantiateAsync实例化的任何Addressable资产,即默认情况下会自动释放。)
Using Addressables in a Scene
If a Scene is itself Addressable, you can use Addressable assets in the scene just as you would any assets. You can place Prefabs and other assets in the Scene, assign assets to component properties, and so on. If you use an asset that is not Addressable, that asset becomes an implicit dependency of the Scene and the build system packs it in the same AssetBundle as the Scene when you make a content build. (Addressable assets are packed into their own AssetBundles according to the group they are in.)
译:如果场景本身是Addressable,则可以像使用任何资产一样在场景中使用Addressable资产。您可以将Prefabs和其他资产放在场景中,将资产分配给组件属性等等。如果使用的资产不是Addressable,则该资产成为场景的隐式依赖项,并且在制作内容构建时,构建系统将其打包到与场景相同的AssetBundle中。(Addressable资产按照它们所在的组分别打包到自己的AssetBundles中。)
NOTE
Implicit dependencies used in more than one place can be duplicated in multiple AssetBundles and in the built-in scene data. Use the Check Duplicate Bundle Dependencies rule in the Analyze tool to find unwanted duplication of assets.
译:在多个位置使用的隐式依赖项可能会在多个AssetBundle和内置场景数据中重复。使用Analyze工具中的检查重复Bundle依赖项规则来查找不需要的资产重复
If a Scene is NOT Addressable, then any Addressable assets you add directly to the scene hierarchy become implicit dependencies and Unity includes copies of those assets in the built-in scene data even if they also exist in an Addressable group. The same is true for any assets, such as Materials, assigned to a component on a GameObject in the scene.
译:如果场景不是Addressable,则直接添加到场景层次结构中的任何Addressable资产都将成为隐式依赖项,即使它们也存在于Addressable组中,Unity也会在内置场景数据中包含这些资产的副本。对于在场景中的GameObject上分配给组件的任何资产,例如材质,也是如此
In custom component classes, you can use AssetReference fields to allow the assignment of Addressable assets in non-Addressable scenes. Otherwise, you can use addresses and labels to load assets at runtime from a script. Note that you must load an AssetReference in code whether or not the Scene is Addressable.
译:在自定义组件类中,您可以使用AssetReference字段允许在非Addressable场景中分配Addressable资产。否则,您可以使用地址和标签从脚本中在运行时加载资产。请注意,无论场景是否是Addressable,您都必须在代码中加载AssetReference