获取AssetBundle文件的数据信息

有时加载的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)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 翻译:莫铭原文地址:AssetBundle usage patterns 本系列中的上一篇文章覆盖了AssetBu...
    莫铭阅读 5,439评论 1 12
  • 这部分主要讨论了AssetBundle的如下知识: AssetBundle的基础知识 使用AssetBundle的...
    Wenchao阅读 1,683评论 0 5
  • 这一部分主要是对Unity的Resources系统和AssetBundle系统进行深入讨论。 分为四个部分: 有关...
    Wenchao阅读 2,077评论 0 1
  • 这一章来说说AssetBundles,介绍下它的基础系统,还有一些和AssetBundles进行交互的核心API。...
    莫铭阅读 2,912评论 6 10
  • 杨幂老公刘恺威,是一个帅,也不帅的男人。说他帅吧,仔细看,脸上的缺点很明显,眼睛不大,嘴尤其不好看,说话还是歪的。...
    颓废的蚂蚁阅读 381评论 0 0