存档使用的压缩类型。
仅当存档加载成功时才能访问。
其他资源:AssetBundles 压缩。
using Unity.Content; using Unity.IO.Archive; using UnityEditor; using UnityEngine;
public static class ArchiveUtilities { #if UNITY_EDITOR [MenuItem("Debug/Check Archive Compression")] static public void CheckCompression() { string archivePath = EditorUtility.OpenFilePanel("Pick AssetBundle or other Unity Archive file", "", ""); if (archivePath.Length == 0) return;
Debug.Log($"Bundle {archivePath} has compression type {GetArchiveCompression(archivePath)}"); } #endif
static public UnityEngine.CompressionType GetArchiveCompression(string archivePath) { var archiveHandle = ArchiveFileInterface.MountAsync(ContentNamespace.Default, archivePath, "temp:"); archiveHandle.JobHandle.Complete();
if (archiveHandle.Status == ArchiveStatus.Failed) throw new System.ArgumentException($"Failed to load {archivePath}");
var compression = archiveHandle.Compression; archiveHandle.Unmount().Complete();
return compression; } }