Unity_Addressable_Addressables Initialization(初始化)
The Addressables system initializes itself at runtime the first time you load an Addressable or make another call to an Addressable API. Call Addressables.InitializeAsync to initialize Addressables earlier (this function does nothing if initialization has already occurred).
译:Addressables系统在您首次加载Addressable或调用其他Addressable API时在运行时初始化自身。调用Addressables.InitializeAsync以更早地初始化Addressables(如果已经初始化,则此函数不执行任何操作)
The initialization operation performs the following tasks:
译:初始化操作执行以下任务:
Sets up the ResourceManager and the ResourceLocators.译:设置ResourceManager和ResourceLocators。
Loads configuration data created by Addressables from StreamingAssets.译:从StreamingAssets加载由Addressables创建的配置数据。
Executes any initialization object operations.译:执行任何初始化对象操作。
Loads the content catalog. By default, Addressables first checks for updates to the content catalog and downloads a new catalog if available.译:加载内容目录。默认情况下,Addressables首先检查内容目录的更新,并在可用时下载新目录。
The following Addressables settings can change initialization behavior:
译:以下Addressables设置可以更改初始化行为:
Only update catalogs manually: Addressables won't automatically check for an updated catalog. See Updating catalogs for information about manually updating your catalogs.译:仅手动更新目录:Addressables不会自动检查更新的目录。有关手动更新目录的信息,请参见更新目录。
Build Remote Catalog: Addressables won't attempt to load remote content without a remote catalog.译:构建远程目录:Addressables不会尝试加载没有远程目录的远程内容。
Custom certificate handler: identify a custom certificate handler if you need one to access your remote asset hosting service.译:自定义证书处理程序:如果需要访问远程资产托管服务,则标识自定义证书处理程序。
Initialization object list: add IObjectInitializationDataProvider ScriptableObjects to your application that are invoked during the initialization operation.译:初始化对象列表:将IObjectInitializationDataProvider ScriptableObjects添加到应用程序中,在初始化操作期间调用它们。
The following runtime properties should be set before the initialization operation starts:
译:在初始化操作开始之前,应设置以下运行时属性:
Custom URL transform function译:自定义URL转换函数
ResourceManager exception handler译:ResourceManager异常处理程序
Static properties used for any custom runtime placeholders in your Profile variables译:在Profile变量中使用任何自定义运行时占位符的静态属性
Initialization objects
You can attach objects to the Addressable Assets settings and pass them to the initialization process at runtime. For example, you can create a CacheInitializationSettings object to initialize Unity's Cache settings at runtime. To create your own types of initialization object, create a ScriptableObject that implements the IObjectInitializationDataProvider interface. Use this object to create the ObjectInitializationData asset that Addressables includes with your the runtime data.
译:您可以将对象附加到Addressable Assets设置并在运行时将它们传递给初始化进程。例如,您可以创建一个CacheInitializationSettings对象,在运行时初始化Unity的缓存设置。要创建自己类型的初始化对象,请创建实现IObjectInitializationDataProvider接口的ScriptableObject。使用此对象创建ObjectInitializationData资产,Addressables会将其与运行时数据一起包含。
Cache initialization objects
Use a CacheInitializationSettings object to initialize Unity's Cache settings at runtime.
译:使用CacheInitializationSettings对象在运行时初始化Unity的缓存设置。
To specify the cache initialization settings that the Addressables system should use:
译:要指定Addressables系统应使用的缓存初始化设置:
Create the CacheInitializationSettings asset (menu: Assets > Addressables > Initialization > Cache Initialization Settings).译:创建CacheInitializationSettings资产(菜单:Assets> Addressables> Initialization> Cache Initialization Settings)
Select the new asset file in the Project panel to view the settings in the Inspector 译:在项目面板中选择新的资产文件以在检查器中查看设置

Adjust the settings as desired.译:根据需要调整设置
Open the Addressables Settings Inspector (menu: Window > Asset Management > Addressables > Settings).译:打开Addressables设置检查器(菜单:Window> Asset Management> Addressables> Settings)
In the Initialization Objects section of the Inspector, click the + button to add a new object to the list.译:在检查器的初始化对象部分中,单击+按钮以向列表中添加新对象
Select your CacheInitializationSettings asset in the File dialog and click Open.译:在文件对话框中选择您的CacheInitializationSettings资产,然后单击打开
The cache settings object is added to the list. 译:缓存设置对象将添加到列表中

When Addressables initializes at runtime, it applies these settings to the default Unity Cache. The settings apply to all AssetBundles in the default cache, not just those downloaded by the Addressables system. See Caching for more information about the Unity cache system.
译:当Addressables在运行时初始化时,它将这些设置应用于默认的Unity缓存。这些设置适用于默认缓存中的所有AssetBundles,而不仅仅是Addressables系统下载的那些。有关Unity缓存系统的更多信息,请参见缓存
NOTE
Android applications built with Unity 2020.1 or earlier or running on Android 9 or earlier can only play videos from uncompressed AssetBundles. You can use a CacheInitializationSettings
object to disable recompression of the cache by disabling the Compress Bundles option.
译:使用Unity 202.1或更早版本构建的Android应用程序或在Android 9或更早版本上运行的应用程序只能从未压缩的AssetBundle中播放视频。可以使用CacheInitializationSettings对象通过禁用压缩Bundle选项来禁用缓存的重新压缩。