欢迎光临散文网 会员登陆 & 注册

Unity_Addressable_Getting addresses at runtime(在运行时获取addresses )

2023-04-12 09:39 作者:unity_某某师_高锦锦  | 我要投稿

Getting addresses at runtime

By default, Addressables uses the address you assign to an asset as the PrimaryKey value of its IResourceLocation instance. (If you disable the Include Addresses in Catalog option of the Addressables group to which the asset belongs, the PrimaryKey could be a GUID, label, or an empty string.) If you want to get the address of an asset that you load with an AssetReference or label, you can first load the asset's locations, as described in Loading Assets by Location. You can then use the IResourceLocation instance to both access the PrimaryKey value and to load the asset.

译:默认情况下,Addressables将您为资产分配的地址用作其IResourceLocation实例的PrimaryKey值。(如果禁用了所属于资产的Addressables组中的Include Addresses in Catalog选项,则PrimaryKey可能是GUID、标签或空字符串。)如果要获取使用AssetReference或标签加载的资产的地址,可以首先加载资产的位置,如“按位置加载资产”所述。然后可以使用IResourceLocation实例来访问PrimaryKey值和加载资产。

The following example gets the address of the asset assigned to an AssetReference object named MyRef1:以下示例获取分配给名为MyRef1的AssetReference对象的资产的地址:

译:

Labels often refer to multiple assets. The following example illustrates how to load multiple Prefab assets and use their primary key value to add them to a dictionary:

译:标签通常引用多个资产。以下示例说明如何加载多个Prefab资产并使用它们的主键值将它们添加到字典中:



Unity_Addressable_Getting addresses at runtime(在运行时获取addresses )的评论 (共 条)

分享到微博请遵守国家法律