本页面介绍了如何配置 Android Performance Tuner 以在 Unity 中包含 Addressables 场景。
Addressables 允许开发者在运行时动态加载内容。这可能包括在构建 .apk 时未在 Unity 构建设置中存在的场景。在 Android Performance Tuner 1.5.1 之前,这些场景未被 Android Performance Tuner 识别,也无法在 Play 管理中心进行检查。
要求
对 Addressables 场景的支持有以下要求:
- Android Performance Tuner 1.5.1 或更高版本
- Unity 2019.3 或更高版本
- Addressables 软件包 1.19.4 或更高版本
添加 Addressables 场景
要让 Android Performance Tuner 识别您的 Addressables 场景,请执行以下操作:
当您准备好测试应用时,请依次前往 Window > Android Performance Tuner > Setup,然后打开 Addressables Settings 标签页。
图 1. Addressables 设置窗口。
点击 Update Addressables Scenes 按钮。
默认情况下,AddressableAssetSettingsDefaultObject
中包含的所有场景都包含在 Android Performance Tuner 中。窗口现在显示了所有找到的场景及其在 proto 文件中保存的值的列表。
图 2. Android Performance Tuner 列出的 Addressables 场景。
要更改从中提取场景的 Addressable Settings Object,请执行以下操作:
转到 Assets/AndroidPerformanceTuner_gen/Runtime/Resources 文件夹,然后在 Inspector 中打开 SetupConfig 脚本化对象。
在 Addressables Settings Object Path 字段中插入您的自定义 Settings Object 的路径,包括文件名。
我们建议您在场景布局半最终确定时更新 Addressables 场景,以避免向后兼容性问题。
Android Performance Tuner 仅收集已上传到 Play 管理中心的 .apk 文件中存在的场景的数据。
重置 Addressables 场景
您可以通过点击 Addressables Settings 标签页中的 Reset Addressables Scenes 来重置您的 Addressables 场景。但是,这会破坏与当前已发布应用版本的兼容性。
在应用中动态更新 SetupConfig
对象而不发布新版本将导致 Play 管理中心出现错误,因为场景与值的关系将无法保留。
在注解中设置 Addressables 场景
如果您使用默认注解,Android Performance Tuner 会自动设置正确的场景。如果您使用自定义注解,请调用 ConvertAddressableScenePathToAPTSceneIndex()
tuner.SetCurrentAnnotation(new Annotation
{
Scene = (Scene) tuner.ConvertAddressableScenePathToAPTSceneIndex(scenePath),
Difficulty = Difficulty.Medium
});