有时加载的AssetBundle文件会出现异常,比如引用丢失之类的问题,就需要我们获取到当前AssetBundle文件中的相关信息。使用Unity内置的工具就可以获取到相关信息。
-
工具目录位置
- mac
/Applications/Unity/Unity.app/Contents/Tools
- windows
C:\Program Files\Unity\Editor\Data\Tools
-
相关工具
-
WebExtract
将AssetBundle中的数据信息解析为二进制文件// 导出到当前路径的子目录中 ./WebExtract assetbundlefile
-
binary2text
将上一步中的二进制文件解析为记录了引用等信息的文本文件./binary2text binarydataPath outputPath
-
注意
- 直接运行以上命令可以查看所需参数
- 工具的unity版本要与生成assetbundle的unity版本一致
-
-
最终得到的文本文件中包含了
- 资源类型及数据结构
- AssetBundleName
- 引用资源
- 被引用资源
- 其它信息
-
范例
一个材质matCube.mat
通过依赖打包后,再被解析出的文件如下:
External References
path(1): "archive:/cab-44fe2819cb4a15306ccad78cf746391a/cab-44fe2819cb4a15306ccad78cf746391a" GUID: 00000000000000000000000000000000 Type: 0
path(2): "archive:/cab-23025caa3b76893fa1854f12632fb434/cab-23025caa3b76893fa1854f12632fb434" GUID: 00000000000000000000000000000000 Type: 0
ID: -5138565447120358643 (ClassID: 21) Material
m_Name "matCube" (string)
m_Shader (PPtr<Shader>)
m_FileID 1 (int)
m_PathID 8470779717659199670 (SInt64)
m_ShaderKeywords "_EMISSION" (string)
m_LightmapFlags 1 (unsigned int)
m_EnableInstancingVariants 0 (bool)
m_DoubleSidedGI 0 (bool)
m_CustomRenderQueue -1 (int)
stringTagMap (map)
size 0 (int)
disabledShaderPasses (vector)
size 0 (int)
m_SavedProperties (UnityPropertySheet)
m_TexEnvs (map)
size 1 (int)
data (pair)
first "_MainTex" (string)
second (UnityTexEnv)
m_Texture (PPtr<Texture>)
m_FileID 2 (int)
m_PathID 576367333583433997 (SInt64)
m_Scale (1 1) (Vector2f)
m_Offset (0 0) (Vector2f)
m_Floats (map)
size 16 (int)
data (pair)
first "_BumpScale" (string)
second 1 (float)
data (pair)
first "_Cutoff" (string)
second 0.5 (float)
data (pair)
first "_DetailNormalMapScale" (string)
second 1 (float)
data (pair)
first "_DstBlend" (string)
second 0 (float)
data (pair)
first "_GlossMapScale" (string)
second 1 (float)
data (pair)
first "_Glossiness" (string)
second 0.5 (float)
data (pair)
first "_GlossyReflections" (string)
second 1 (float)
data (pair)
first "_Metallic" (string)
second 0 (float)
data (pair)
first "_Mode" (string)
second 0 (float)
data (pair)
first "_OcclusionStrength" (string)
second 1 (float)
data (pair)
first "_Parallax" (string)
second 0.02 (float)
data (pair)
first "_SmoothnessTextureChannel" (string)
second 0 (float)
data (pair)
first "_SpecularHighlights" (string)
second 1 (float)
data (pair)
first "_SrcBlend" (string)
second 1 (float)
data (pair)
first "_UVSec" (string)
second 0 (float)
data (pair)
first "_ZWrite" (string)
second 1 (float)
m_Colors (map)
size 2 (int)
data (pair)
first "_Color" (string)
second (1 1 1 1) (ColorRGBA)
data (pair)
first "_EmissionColor" (string)
second (0 0 0 1) (ColorRGBA)
ID: 1 (ClassID: 142) AssetBundle
m_Name "scene/matcube" (string)
m_PreloadTable (vector)
size 3 (int)
data (PPtr<Object>)
m_FileID 2 (int)
m_PathID 576367333583433997 (SInt64)
data (PPtr<Object>)
m_FileID 0 (int)
m_PathID -5138565447120358643 (SInt64)
data (PPtr<Object>)
m_FileID 1 (int)
m_PathID 8470779717659199670 (SInt64)
m_Container (map)
size 1 (int)
data (pair)
first "assets/resources/scene/matcube.mat" (string)
second (AssetInfo)
preloadIndex 0 (int)
preloadSize 3 (int)
asset (PPtr<Object>)
m_FileID 0 (int)
m_PathID -5138565447120358643 (SInt64)
m_MainAsset (AssetInfo)
preloadIndex 0 (int)
preloadSize 0 (int)
asset (PPtr<Object>)
m_FileID 0 (int)
m_PathID 0 (SInt64)
m_RuntimeCompatibility 1 (unsigned int)
m_AssetBundleName "scene/matcube" (string)
m_Dependencies (vector)
size 2 (int)
data "shader/wxl/texture" (string)
data "scene/texsky" (string)
m_IsStreamedSceneAssetBundle 0 (bool)
网友评论