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

Unity_Addressable_

2023-04-11 15:54 作者:unity_某某师_高锦锦  | 我要投稿

By default, the Addressables system manages the catalog automatically at runtime. If you built your application with a remote catalog, the Addressables system automatically checks to see if you have uploaded a new catalog, and, if so, downloads the new version and loads it into memory.

译:在运行时管理目录 默认情况下,Addressables系统会在运行时自动管理目录。如果你使用远程目录构建了应用程序,Addressables系统会自动检查是否上传了新的目录,如果有,就会下载新版本并加载到内存中。

You can load additional catalogs at runtime. For example, you could load a catalog produced by a separate, compatible project to load Addressable assets built by that project. (See Loading Content from Multiple Projects.)

译:你可以在运行时加载额外的目录。例如,你可以加载由另一个兼容项目生成的目录,以加载该项目构建的Addressable资源。(请参阅从多个项目加载内容。)

If you want to change the default catalog update behavior of the Addressables system, you can turn off the automatic check and check for updates manually. See Updating catalogs.

译:如果你想改变Addressables系统的默认目录更新行为,你可以关闭自动检查并手动检查更新。请参阅更新目录。

Loading additional catalogs

Use Addressables.LoadContentCatalogAsync to load additional content catalogs, either from your hosting service or from the local file system. All that is required is for you to supply the location of the catalog you wish to load. After the operation to load the catalog is finished, you can call any Addressables loading functions using the keys in the new catalog.

译:加载额外的目录 使用Addressables.LoadContentCatalogAsync来加载额外的内容目录,可以来自你的托管服务或本地文件系统。你只需要提供要加载的目录位置即可。加载目录的操作完成后,你可以使用新目录中的键调用任何Addressables加载函数。

If you provide the catalog hash file at the same URL as the catalog, Addressables caches the secondary catalog. When the client application loads the catalog in the future, it only downloads a new version of the catalog if the hash changes.

译:如果你在与目录相同的URL上提供了目录哈希文件,Addressables会缓存次要目录。当客户端应用程序在将来加载目录时,仅在哈希值更改时才会下载目录的新版本。

NOTE

  • The hash file does need to be in the same location and have the same name as your catalog. The only difference to the path should be the extension.译:哈希文件需要与你的目录位于相同的位置并具有相同的名称。路径的唯一差异应该是扩展名。

  • LoadContentCatalogAsync comes with a parameter autoReleaseHandle. In order for the system to download a new remote catalog, any prior calls to LoadContentCatalogAsync that point to the catalog you're attempting to load need to be released. Otherwise, the system picks up the Content Catalog load operation from our operation cache. If the cached operation is picked up, the new remote catalog is not downloaded. If set to true, the parameter autoReleaseHandle can ensure that the operation doesn't stick around in our operation cache after completing.译:LoadContentCatalogAsync带有参数autoReleaseHandle。为了使系统下载新的远程目录,任何指向你要加载的目录的之前的LoadContentCatalogAsync调用都需要被释放。否则,系统会从我们的操作缓存中获取Content Catalog加载操作。如果选择了缓存操作,则不会下载新的远程目录。如果设置为true,参数autoReleaseHandle可以确保操作在完成后不会留在我们的操作缓存中。

Once you load a catalog, you cannot unload it. You can, however, update a loaded catalog. You must release the operation handle for the operation that loaded the catalog before updating a catalog. See Updating catalogs for more information.

译:一旦你加载了目录,就无法卸载它。但是,你可以更新已加载的目录。在更新目录之前,必须释放加载目录的操作句柄。请参阅更新目录以获取更多信息。

In general, there is no reason to hold on to the operation handle after loading a catalog. You can release it automatically by setting the autoReleaseHandle parameter to true when loading a catalog, as shown in the following example:

译:通常情况下,加载目录后没有保留操作句柄的原因。你可以在加载目录时将autoReleaseHandle参数设置为true以自动释放它,如以下示例所示:

NOTE

You can use the Catalog Download Timeout property of your Addressables settings to specify a timeout for downloading catalogs.

译:你可以使用Addressables设置的目录下载超时属性来指定下载目录的超时时间。

Updating catalogs

If the catalog hash file is available, Addressables checks the hash when loading a catalog to determine if the version at the provided URL is more recent than the cached version of the catalog. You can turn off the default catalog check, if desired, and call the Addressables.UpdateCatalogs function when you want to update the catalog. If you loaded a catalog manually with LoadContentCatalogAsync, you must release the operation handle before you can update the catalog.

译:更新目录 如果目录哈希文件可用,Addressables会在加载目录时检查哈希值,以确定提供的URL上的版本是否比目录的缓存版本更新。如果需要,你可以关闭默认目录检查,并在想要更新目录时调用Addressables.UpdateCatalogs函数。如果你使用LoadContentCatalogAsync手动加载了目录,则必须在更新目录之前释放操作句柄。

When you call the UpdateCatalog function, all other Addressable requests are blocked until the operation is finished. You can release the operation handle returned by UpdateCatalogs immediately after the operation finishes (or set the autoRelease parameter to true).

译:当您调用UpdateCatalog函数时,直到操作完成之前,所有其他的Addressable请求都会被阻塞。您可以在操作完成后立即释放UpdateCatalogs返回的操作句柄(或将autoRelease参数设置为true)。

If you call UpdateCatalog without providing a list of catalogs, Addressables checks all of the currently loaded catalogs for updates.

译:如果调用UpdateCatalog而不提供目录列表,则Addressables将检查所有当前加载的目录以获取更新。

You can also call Addressables.CheckForCatalogUpdates directly to get the list of catalogs that have updates and then perform the update:

译:您也可以直接调用Addressables.CheckForCatalogUpdates来获取有更新的目录列表,然后执行更新:

IMPORTANT

If you update a catalog when you have already loaded content from the related AssetBundles, you can encounter conflicts between the loaded AssetBundles and the updated versions. You can enable the Unique Bundle Ids option in your Addressable settings to eliminate the possibility of bundle ID collisions at runtime. However, enabling this option also means that more AssetBundles must typically be rebuilt when you perform a content update. See Content update builds for more information. Another option is to first unload any content and AssetBundles that must be updated, which can be a slow operation.

译:重要提示:如果在已加载相关AssetBundles的情况下更新目录,则可能会遇到已加载的AssetBundles和已更新版本之间的冲突。您可以在Addressable设置中启用唯一Bundle Ids选项,以消除运行时bundle ID冲突的可能性。但是,启用此选项也意味着在执行内容更新时通常必须重新构建更多的AssetBundles。有关详细信息,请参见内容更新构建。另一个选择是首先卸载必须更新的任何内容和AssetBundles,这可能是一个缓慢的操作。




Unity_Addressable_的评论 (共 条)

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