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

Unity_Addressable_Content Packing & Loading Schema(内容包装和装载模式)

2023-03-31 00:32 作者:unity_某某师_高锦锦  | 我要投稿

Build and Load Paths

The Build and Load Paths settings of the Content Packing & Loading schema determine where the artifacts for your content builds are created and where the Addressables system should look for them at runtime.

译:Content Packing&Loading模式的构建和加载路径设置确定内容构建的工件在哪里创建,以及Addressables系统在运行时应该在哪里查找它们。

构建和加载路径

Setting                                                                                Purpose

Build & Load PathsThe Profile path pair that defines where the Addressables build system creates artifacts for this group and where the Addressables system loads those artifacts at runtime. Choose a path pair from the list or select <custom> if you want to set the build and load paths separately.译:构建和加载路径配置文件路径对,定义Addressables构建系统在此组中创建工件的位置,以及Addressables系统在运行时加载这些工件的位置。从列表中选择一个路径对,或者选择,如果您想单独设置构建和加载路径。

Build PathA Profile variable that defines where the Addressables build system creates artifacts for this group. You can also set a custom string. Use one of the following for the build path:译:构建路径用于为此组定义Addressables构建系统创建工件的配置文件变量。您还可以设置自定义字符串。对于构建路径,请使用以下之一:

LocalBuildPath: use for assets that you plan to distribute as part of your application installation.译:用于您计划作为应用程序安装的一部分分发的资产。

RemoteBuildPath: use for assets that you plan to distribute using a remote hosting service such Unity Cloud Content Delivery or other Content Delivery Network.译:用于您计划使用远程主机服务(如Unity Cloud内容交付或其他内容交付网络)分发的资产。

<custom>: specify a string as the build path for this group.译:指定字符串作为此组的构建路径。

Only shown if you set Build & Load Paths to <custom>.Load PathA Profile variable that defines where the Addressables system loads the build artifacts for this group at runtime. You can also set a custom string. Use one of the following for the load path:译:仅在将Build&Load Paths设置为时显示。 加载路径用于为此组定义Addressables系统在运行时加载构建工件的配置文件变量。您还可以设置自定义字符串。对于加载路径,请使用以下之一:


LocalLoadPath: use for assets that you plan to distribute as part of your application installation.译:用于您计划作为应用程序安装的一部分分发的资产。

RemoteLoadPath: use for assets that you plan to distribute using a remote hosting service such Unity Cloud Content Delivery or other Content Delivery Network.译:用于您计划使用远程主机服务(如Unity Cloud内容交付或其他内容交付网络)分发的资产。

<custom>: specify a string as the load path for this group.译:指定字符串作为此组的加载路径。

Only shown if you set Build & Load Paths to <custom>.译:仅在将Build&Load Paths设置为时显示。


The build and load path options are defined by variables in your Profiles. Note that only variables intended for a given purpose should be used for a setting. For example, choosing a load path variable for a build path setting wouldn't give you a useful result.

译:构建和加载路径选项由Profiles中的变量定义。请注意,应仅使用用于特定目的的变量进行设置。例如,为构建路径设置加载路径变量不会给您有用的结果。

When you choose a Profile variable, the current evaluation of the path is shown in the Path Preview. Components of the path in braces, such as {UnityEngine.AddressableAssets.Addressable.RuntimePath}, indicate that static variable is used to construct the final path at runtime. That portion of the path is replaced by the current value of the static variable when the Addressables system initializes at runtime.

译:

当您选择配置文件变量时,路径预览中显示路径的当前评估。在括号中的路径组件(例如{UnityEngine.AddressableAssets.Addressable.RuntimePath})表示在运行时使用静态变量构建最终路径。该路径部分在Addressables系统在运行时初始化时由静态变量的当前值替换。


WARNING

In most cases, you should not change the local build or load paths from their default values. If you do, you must copy the local build artifacts from your custom build location to the project's [StreamingAssets] folder before making a Player build. Altering these paths also precludes building your Addressables as part of the Player build.

译:在大多数情况下,您不应更改本地构建或加载路径的默认值。如果这样做,您必须在制作Player构建之前将本地构建工件从自定义构建位置复制到项目的[StreamingAssets]文件夹中。更改这些路径还会排除将您的Addressables作为Player构建的一部分构建。

See Profiles for more information.

译:

Advanced Options

高级选项部分

Setting                                                Purpose

Asset Bundle CompressionThe compression type for all bundles produced from the group. LZ4 is usually the most efficient option, but other options can be better in specific circumstances. See AssetBundle Compression for more information.译:资产捆绑压缩此组生成的所有捆绑包的压缩类型。LZ4通常是最有效的选项,但其他选项可以在特定情况下更好。有关更多信息,请参见AssetBundle Compression。

Include In BuildWhether to include assets in this group in a content build.译:包括在构建中是否在此组中包括资产。

Force Unique ProviderWhether Addressables uses unique instances of Resource Provider classes for this group. Enable this option if you have custom Provider implementations for the asset types in this group and instances of those Providers must not be shared between groups.译:强制使用唯一的提供程序是否Addressables为此组使用资源提供程序类的唯一实例。如果您对此组中的资产类型进行了自定义提供程序实现,并且这些提供程序的实例不能在组之间共享,则启用此选项。

Use Asset Bundle CacheWhether to cache remotely distributed bundles.译:使用资产捆绑缓存是否要缓存远程分布式捆绑包。

Asset Bundle CRCWhether to verify a bundle's integrity before loading it.译:资产捆绑CRC是否在加载捆绑包之前验证其完整性。

• Disabled: Never check bundle integrity.译:•已禁用:从不检查捆绑包完整性。

• Enabled, Including Cached: Always check bundle integrity.译:•启用,包括缓存:始终检查捆绑包完整性。

• Enabled, Excluding Cached: Check integrity of bundles when downloading.译:•启用,不包括缓存:在下载时检查捆绑包的完整性。

Use UnityWebRequest for Local Asset BundlesLoad local AssetBundle archives from this group using UnityWebRequestAssetBundle.GetAssetBundle instead译:使用UnityWebRequest加载本地AssetBundle归档文件,而不是使用AssetBundle.LoadFromFileAsync。 of AssetBundle.LoadFromFileAsync.译:

Request TimeoutThe timeout interval for downloading remote bundles.译:请求超时:下载远程捆绑包的超时时间间隔。

Use Http Chunked TransferWhether to use the HTTP/1.1 chunked-transfer encoding method when downloading bundles.
Deprecated and ignored in Unity 2019.3+.译:使用Http Chunked Transfer:在下载捆绑包时是否使用HTTP / 1.1分块传输编码方法。 在Unity 2019.3+中已弃用并忽略。

Http Redirect LimitThe number of redirects allowed when downloading bundles. Set to -1 for no limit.译:Http重定向限制:下载捆绑包时允许的重定向次数。将其设置为-1表示没有限制。

Retry CountThe number of times to retry failed downloads.译:重试次数:重试下载失败的次数。

Include Addresses in CatalogWhether to include the address strings in the catalog. If you don't load assets in the group using their address strings, you can decrease the size of the catalog by not including them.译:在目录中包含地址:是否在目录中包含地址字符串。如果不使用地址字符串加载组中的资源,则可以通过不包含它们来减小目录的大小。

Include GUIDs in CatalogWhether to include GUID strings in the catalog. You must include GUID strings to access an asset with an AssetReference. If you don't load assets in the group using AssetReferences or GUID strings, you can decrease the size of the catalog by not including them.译:在目录中包含GUID:是否在目录中包含GUID字符串。如果使用AssetReference访问资源,则必须包含GUID字符串。如果不使用AssetReferences或GUID字符串加载组中的资源,则可以通过不包含它们来减小目录的大小。

Include Labels in CatalogWhether to include label strings in the catalog. If you don't load assets in the group using labels, you can decrease the size of the catalog by not including them.译:在目录中包含标签:是否在目录中包含标签字符串。如果不使用标签加载组中的资源,则可以通过不包含它们来减小目录的大小。

Internal Asset Naming ModeDetermines the identification of assets in AssetBundles and is used to load the asset from the bundle. This value is used as the internalId of the asset Location. Changing this setting affects a bundles CRC and Hash value.
译:内部资产命名模式:确定AssetBundles中资产的标识方式,并用于从捆绑包中加载资产。此值用作资产位置的internalId。更改此设置会影响Bundle的CRC和Hash值。

Warning: Do not modify this setting for Content update builds. The data stored in the content state file will become invalid.译:警告:不要为内容更新构建修改此设置。内容状态文件中存储的数据将变为无效。


The different modes are:
Full Path: the path of the asset in your project. This mode is recommended to use during development because it allows you to identify Assets being loaded by their ID if needed.译:完整路径:项目中资产的路径。在开发过程中推荐使用此模式,因为它允许您根据需要通过其ID标识正在加载的资产。

Filename: the asset's filename. This can also be used to identify an asset. Note: You cannot have multiple assets with the same name.译:文件名:资产的文件名。这也可以用于标识资产。注意:您不能具有相同名称的多个资产。

GUID: a deterministic value for the asset.译:GUID:资产的确定性值。

Dynamic: the shortest id that can be constructed based on the assets in the group. This mode is recommended to use for release because it can reduce the amount of data in the AssetBundle and catalog, and lower runtime memory overhead.译:动态:基于组中的资产可以构建的最短ID。在发布时推荐使用此模式,因为它可以减少AssetBundle和目录中的数据量,并降低运行时内存开销。

Internal Bundle Id ModeDetermines how an AssetBundle is identified internally. This affects how an AssetBundle locates dependencies that are contained in other bundles. Changing this value affects the CRC and Hash of this bundle and all other bundles that reference it.译:内部Bundle Id模式:确定如何在内部标识AssetBundle。这会影响AssetBundle定位包含在其他Bundle中的依赖项的方式。更改此值会影响此Bundle及引用它的所有其他Bundle的CRC和Hash。

Warning: Do not modify this setting for Content update builds. The data stored in the content state file will become invalid.译:要为内容更新构建修改此设置。内容状态文件中存储的数据将变为无效。The different modes are:
Group Guid: unique identifier for the Group. This mode is recommended to use as it does not change.译:Group Guid:组的唯一标识符。推荐使用此模式,因为它不会更改。

Group Guid Project Id Hash: uses a combination of the Group GUID and the Cloud Project Id (if Cloud Services are enabled). This changes if the Project is bound to a different Cloud Project Id. This mode is recommended when sharing assets between multiple projects because the id constructed is deterministic and unique between projects.译:Group Guid Project Id Hash:使用组GUID和云项目ID(如果启用了云服务)的组合。如果项目绑定到不同的Cloud Project Id,则会更改此值的构造方式。当在多个项目之间共享资产时,建议使用此模式,因为它构建的ID是确定性的且在项目之间唯一。

Group Guid Project Id Entries Hash: uses a combination of the Group GUID, Cloud Project Id (if Cloud Services are enabled), and asset entries in the Group. Note that using this mode can easily cause bundle cache version issues. Adding or removing entries results in a different hash.译:Group Guid Project Id Entries Hash:使用组GUID,云项目ID(如果启用了云服务)和组中的资产条目的组合。请注意,使用此模式很容易造成捆绑包缓存版本问题。添加或删除条目会导致不同的哈希值。

Cache Clear BehaviorDetermines when an installed application clears AssetBundles from the cache.译:Cache Clear Behavior:确定已安装的应用程序何时清除AssetBundles缓存。

Bundle ModeHow to pack the assets in this group into bundles:译:Bundle Mode:如何将该组中的资产打包到Bundle中:

Pack Together: create a single bundle containing all assets.译:Pack Together:创建包含所有资产的单个Bundle。

Pack Separately: create a bundle for each primary asset in the group. Subassets, such as Sprites in a Sprite sheet are packed together. Assets within a folder added to the group are also packed together.译:Pack Separately:为该组中的每个主要资产创建一个Bundle。Sprite Sheet中的Sprites等子资产将被打包在一起。添加到该组的文件夹中的资产也将被打包在一起。

Pack Together by Label: create a bundle for assets sharing the same combination of labels.译:Pack Together by Label:为共享相同标签组合的资产创建一个Bundle。

Bundle Naming ModeHow to construct the file names of AssetBundles:译:Bundle Naming Mode:如何构建AssetBundles的文件名:

Filename: the filename is a string derived from the group name. No hash is appended to it.译:Filename:文件名是从组名称派生的字符串。不在其后附加哈希值。

Append Hash to Filename: the filename is a string derived from the group name with bundle hash appended to it. The bundle hash is calculated using the contents of the bundle.译:Append Hash to Filename:文件名是从组名称派生的字符串,附加了Bundle哈希值。Bundle哈希值是使用Bundle内容计算的。

Use Hash of AssetBundle: the filename is the bundle hash.译:Use Hash of AssetBundle:文件名是Bundle哈希值。

Use Hash of Filename: the filename is a hash calculated from the a string derived from the group name.译:Use Hash of Filename:文件名是从组名称派生的字符串计算的哈希值。

Asset Load ModeWhether to load assets individually as you request them (the default) or always load all assets in the group together. It is recommended to use Requested Asset and Dependencies for most cases. See Asset Load Mode for more information.译:Asset Load Mode:是否按您请求它们来单独加载资产(默认)或始终一起加载该组中的所有资产。对于大多数情况,建议使用请求的资产和依赖项。有关详细信息,请参见资产加载模式。

Asset ProviderDefines which Provider class Addressables uses to load assets from the AssetBundles generated from this group. Set this option to Assets from Bundles Provider unless you have a custom Provider implementation to provide assets from an AssetBundle.译:Asset Provider:定义Addressables用于从此组生成的AssetBundles加载资产的Provider类。除非您有自定义Provider实现来提供来自AssetBundle的资产,否则请将此选项设置为Bundles Provider。

Asset Bundle ProviderDefines which Provider class Addressables uses to load AssetBundles generated from this group. Set this option to AssetBundle Provider unless you have a custom Provider implementation to provide AssetBundles.译:Asset Bundle Provider:定义Addressables用于加载从此组生成的AssetBundles的Provider类。除非您有自定义Provider实现来提供AssetBundles,否则请将此选项设置为AssetBundle Provider。


AssetBundle Compression

Addressables provides three different options for bundle compression: Uncompressed, LZ4, and LZMA. Generally speaking, LZ4 should be used for local content, and LZMA for remote, but more details are outlined below as there can be exceptions to this.

译:Addressables提供三种不同的Bundle压缩选项:未压缩、LZ4和LZMA。一般来说,LZ4应用于本地内容,LZMA应用于远程内容,但是下面详细说明了更多细节,因为存在例外情况。

You can set the compression option using the Advanced settings on each group. Compression does not affect in-memory size of your loaded content.

译:您可以使用每个组上的高级设置来设置压缩选项。压缩不影响已加载内容的内存大小。

  • Uncompressed - This option is largest on disk, and generally fastest to load. If your game happens to have space to spare, this option should at least be considered for local content. A key advantage of uncompressed bundles is how they handle being patched. If you are developing for a platform where the platform itself provides patching (such as Steam or Switch), uncompressed bundles provide the most accurate (smallest) patching. Either of the other compression options will cause at least some bloat of patches.译:未压缩 - 此选项在磁盘上最大,并且通常加载速度最快。如果您的游戏恰好有足够的空间,那么至少应该考虑此选项用于本地内容。未压缩Bundle的一个关键优势是它们如何处理被打补丁的情况。如果您正在为平台开发,而平台本身提供打补丁的功能(例如Steam或Switch),则未压缩的Bundle提供最准确(最小)的补丁。任何其他压缩选项都会导致某些补丁膨胀。

  • LZ4 - If Uncompressed is not a viable option, then LZ4 should be used for all other local content. This is a chunk-based compression which provides the ability to load parts of the file without needing to load it in its entirety.译:LZ4 - 如果未压缩不可行,则应为所有其他本地内容使用LZ4。这是一种基于块的压缩,它提供了在不需要完全加载文件的情况下加载文件的能力。

  • LZMA - LZMA should be used for all remote content, but not for any local content. It provides the smallest bundle size, but is slow to load. If you were to store local bundles in LZMA you could create a smaller player, but load times would be significantly worse than uncompressed or LZ4. For downloaded bundles, we avoid the slow load time by recompressing the downloaded bundle when storing it in the AssetBundle cache. By default, bundles will be stored in the cache with LZ4 compression.译:LZMA - LZMA应该用于所有远程内容,但不适用于任何本地内容。它提供最小的Bundle大小,但加载速度较慢。如果您将本地Bundle存储在LZMA中,则可以创建较小的播放器,但加载时间将显着恶化,而未压缩或LZ4则不会。对于下载的Bundle,我们通过在存储它们在AssetBundle缓存中时重新压缩已下载的Bundle来避免慢速加载时间。默认情况下,Bundle将使用LZ4压缩存储在缓存中。

NOTE

LZMA AssetBundle compression is not available for AssetBundles on WebGL. LZ4 compression can be used instead. For more WebGL AssetBundle information, see Building and running a WebGL project.

译:LZMA AssetBundle压缩不适用于WebGL上的AssetBundle。可以改用LZ4压缩。有关更多WebGL AssetBundle信息,请参见构建和运行WebGL项目。

Note that the hardware characteristics of a platform can mean that uncompressed bundles are not always the fastest to load. The maximum speed of loading uncompressed bundles is gated by IO speed, while the speed of loading LZ4-compressed bundles can be gated by either IO speed or CPU, depending on hardware. On most platforms, loading LZ4-compressed bundles is CPU bound, and loading uncompressed bundles will be faster. On platforms that have low IO speeds and high CPU speeds, LZ4 loading can be faster. It is always a good practice to run performance analysis to validate whether your game fits the common patterns, or needs some unique tweaking.

译:请注意,平台的硬件特性可能意味着未压缩的Bundle并不总是加载最快的。未压缩Bundle的最大加载速度受IO速度的限制,而加载LZ4压缩的Bundle的速度可以受CPU或IO速度的限制,具体取决于硬件。在大多数平台上,加载LZ4压缩的Bundle是CPU限制的,加载未压缩的Bundle会更快。在具有低IO速度和高CPU速度的平台上,LZ4加载速度可能更快。始终进行性能分析是一种良好的实践,以验证您的游戏是否符合常见模式,或者是否需要进行一些独特的调整。

More information on Unity's compression selection is available in the AssetBundle compression manual page.

译:有关Unity的压缩选择的更多信息,请参见AssetBundle压缩手册页面。

AssetBundle CRC

Different CRC settings are best used depending upon different circumstances. Checking for a change in the file requires the entire AssetBundle to be decompressed and the check processed on the uncompressed bytes. This can impact performance negatively and may not be a worth while trade off. Corruption is likely to only happen during a download, disk storage is generally reliable and unlikely to have corrupted files after saving to disk. if your AssetBundle contains data that may be tampered with such as settings values, then you may want to consider enabling CRC checks on saved AssetBundles.

译:不同的CRC设置最好根据不同的情况使用。检查文件是否更改需要将整个AssetBundle解压缩并处理未压缩的字节上的检查。这可能会对性能产生负面影响,并且可能不值得权衡。损坏可能仅在下载期间发生,磁盘存储通常是可靠的,保存到磁盘后不太可能出现损坏的文件。如果您的AssetBundle包含可能被篡改的数据,例如设置值,则可以考虑在保存的AssetBundle上启用CRC检查。

For local AssetBundles, if the application download performs a check on the download before saving to disk. Then consider setting this to Disabled as the download will have already been checked.

译:对于本地AssetBundle,如果应用程序下载在保存到磁盘之前对下载进行检查。然后请考虑将其设置为Disabled,因为下载已经被检查过了。

For remote AssetBundles, Enabled, Excluding cache is a good default. When downloading and caching an AssetBundle to disk, the bytes are decompressed and a CRC calculation is done during file saving. This will not impact performance and the corruption is most likely to occur during this phase from the download. including cache is good to use where the data needs to be checked everytime such as settings values.

译:对于远程AssetBundle,默认情况下启用Excluding cache是一个好的选择。在下载和缓存AssetBundle到磁盘时,字节将被解压缩,并且在文件保存期间进行CRC计算。这不会影响性能,而且损坏最有可能在下载期间发生。包括缓存是在数据需要每次进行检查的情况下使用的,例如设置值。

Asset Load Mode

For most platforms and collection of content, it is recommended to use Requested Asset and Dependencies. This mode will only load what is required for the Assets requested with LoadAssetAsync or LoadAssetsAsync. Objects are loaded based in the order that they appear in a bundle file, which can result in reading the same file multiple times. Enabling the Contiguous Bundles option in Addressables Build settings can help reduce the number of extra file reads.

译:对于大多数平台和内容集合,建议使用Requested Asset and Dependencies模式。这种模式只会加载使用LoadAssetAsync或LoadAssetsAsync请求的资产所需的内容。对象是基于它们在Bundle文件中出现的顺序加载的,这可能导致多次读取同一文件。在Addressables Build设置中启用Contiguous Bundles选项可以帮助减少额外的文件读取。

This prevents situations where Assets are loaded into memory that are not used.

译:这可以防止将未使用的资产加载到内存中。

Performance in situations where you will load all Assets that are packed together, such as a loading screen. Most types of content will have either have similar or improved performance when loading each individually using Requested Asset and Dependencies mode. This mode sequentially reads entire bundle files, which may be more preferrable in some platforms like the Switch.

译:在需要加载所有打包在一起的资产的情况下(例如加载屏幕等情况)中,大多数类型的内容都将使用请求的资产和依赖项模式逐个加载每个资产,这样可以获得类似或更好的性能。此模式顺序读取整个Bundle文件,这在某些平台(例如Switch)中可能更好。


NOTE

The examples below apply to Desktop and Mobile platforms. Performance may differ between platforms. The All Packed Assets and Dependencies mode typically performs better than loading assets individually on the Nintendo Switch due its hardware and memory reading limitations. It is recommended to profile loading performance for your specific content and platform to see what works for your Application.

译:注意:以下示例适用于桌面和移动平台。性能可能因平台而异。在Nintendo Switch上,All Packed Assets and Dependencies模式通常比单独加载资产表现更好,因为它的硬件和内存读取限制。建议对特定内容和平台进行加载性能分析,以确定适合您的应用程序的解决方案。

Loading performance can vary between content type. As an example, large counts of serialized data such as Prefabs or ScriptableObjects with direct references to other serialized data will load faster using All Packed Assets and Dependencies. With some other Assets like Textures, you can often achieve better performance when you load each Asset individually.

译:资产类型不同,其加载性能可能会有所不同。例如,包含大量序列化数据的资产,如Prefabs或ScriptableObjects,直接引用其他序列化数据,使用All Packed Assets and Dependencies可以更快地加载。对于一些其他的资产,如Textures,单独加载每个资产往往可以获得更好的性能。

If using Synchronous Addressables, there is little performance between between Asset load modes. Because of greater flexibility it is recommended to use Requested Asset and Dependencies where you know the content will be loaded synchronously.

译:如果使用同步地址,各种资产加载模式之间的性能差异很小。由于更大的灵活性,建议在您知道内容将同步加载时使用Requested Asset and Dependencies。

On loading the first Asset with All Packed Assets and Dependencies, all Assets are loaded into memory. Later LoadAssetAsync calls for Assets from that pack will return the preloaded Asset without needing to load it.

译:使用All Packed Assets and Dependencies加载第一个资产时,所有资产都会加载到内存中。以后从该包加载资产的LoadAssetAsync调用将返回预加载的资产,无需加载它。

Even though all the Assets in a group and any dependencies are loaded in memory when you use the All Packed Assets and Dependencies option, the reference count of an individual asset is not incremented unless you explicitly load it (or it is a dependency of an asset that you load explicitly). If you later call Resources.UnloadUnusedAssets, or you load a new Scene using LoadSceneMode.Single, then any unused assets (those with a reference count of zero) are unloaded.

译:即使使用了All Packed Assets and Dependencies选项加载了组中的所有资产和任何依赖项,但除非您显式加载它(或者它是您显式加载的资产的依赖项),否则单个资产的引用计数不会增加。如果您稍后调用Resources.UnloadUnusedAssets或使用LoadSceneMode.Single加载新场景,则会卸载任何未使用的资产(那些引用计数为零的资产)。







Unity_Addressable_Content Packing & Loading Schema(内容包装和装载模式)的评论 (共 条)

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