1. 程式人生 > >Unity3D資源管理架構

Unity3D資源管理架構

在Unity3D引擎中,場景資原始檔(.unity)是以2進位制格式儲存的,但同時它也有一種基於文字的表現格式。可在Edit>Project Setting>Editor 中設定:
這裡寫圖片描述
1.使用binary2text.exe(win下目錄:Editor\Data\Tools)可將.unity檔案轉換成.txt檔案,只需將.unity檔案拖拽到binary2text.exe上即可生成.txt;
這裡寫圖片描述
2.Bin2Text.unity為測試場景場景中只有一個名為“sakyaer”的空物體;
這裡寫圖片描述
3.對應這樣一個場景,它的文字格式使用YAML格式儲存,資訊表如下:

  • ID項為隨記分配給每個例項的唯一標識
  • 資原始檔使用m_作為字首
  • 其中m_GameObject (file 0 path 1163297905)表現transform對gameobject的從屬關係
External References


ID: 1 (ClassID: 29) SceneSettings
    m_ObjectHideFlags 0 (unsigned int)
    m_PVSData  (vector)
        size 0 (int)

    m_PVSObjectsArray  (vector)
        size 0 (int)

    m_PVSPortalsArray  (vector
) size 0 (int) m_OcclusionBakeSettings (OcclusionBakeSettings) smallestOccluder 5 (float) smallestHole 0.25 (float) backfaceThreshold 100 (float) ID: 2 (ClassID: 104) RenderSettings m_Fog 0 (bool) m_FogColor (0.5 0.5 0.5 1) (ColorRGBA) m_FogMode 3 (int) m_FogDensity 0.01
(float) m_LinearFogStart 0 (float) m_LinearFogEnd 300 (float) m_AmbientLight (0.2 0.2 0.2 1) (ColorRGBA) m_SkyboxMaterial (file 0 path 0) (PPtr<Material>) m_HaloStrength 0.5 (float) m_FlareStrength 1 (float) m_FlareFadeSpeed 3 (float) m_HaloTexture (file 0 path 0) (PPtr<Texture2D>) m_SpotCookie (file 0 path 0) (PPtr<Texture2D>) m_ObjectHideFlags 0 (unsigned int) ID: 3 (ClassID: 127) LevelGameManager m_ObjectHideFlags 0 (unsigned int) ID: 4 (ClassID: 157) LightmapSettings m_ObjectHideFlags 0 (unsigned int) m_LightProbes (file 0 path 0) (PPtr<LightProbes>) m_Lightmaps (vector) size 0 (int) m_LightmapsMode 1 (int) m_BakedColorSpace 0 (int) m_UseDualLightmapsInForward 0 (bool) m_LightmapEditorSettings (LightmapEditorSettings) m_Resolution 50 (float) m_LastUsedResolution 0 (float) m_TextureWidth 1024 (int) m_TextureHeight 1024 (int) m_BounceBoost 1 (float) m_BounceIntensity 1 (float) m_SkyLightColor (0.86 0.93 1 1) (ColorRGBA) m_SkyLightIntensity 0 (float) m_Quality 0 (int) m_Bounces 1 (int) m_FinalGatherRays 1000 (int) m_FinalGatherContrastThreshold 0.05 (float) m_FinalGatherGradientThreshold 0 (float) m_FinalGatherInterpolationPoints 15 (int) m_AOAmount 0 (float) m_AOMaxDistance 0.1 (float) m_AOContrast 1 (float) m_LODSurfaceMappingDistance 1 (float) m_Padding 0 (int) m_TextureCompression 0 (bool) m_LockAtlas 0 (bool) ID: 5 (ClassID: 196) NavMeshSettings m_ObjectHideFlags 0 (unsigned int) m_BuildSettings (NavMeshBuildSettings) agentRadius 0.5 (float) agentHeight 2 (float) agentSlope 45 (float) agentClimb 0.4 (float) ledgeDropHeight 0 (float) maxJumpAcrossDistance 0 (float) accuratePlacement 0 (bool) minRegionArea 2 (float) widthInaccuracy 16.6667 (float) heightInaccuracy 10 (float) m_NavMesh (file 0 path 0) (PPtr<NavMesh>) ID: 1163297905 (ClassID: 1) GameObject m_ObjectHideFlags 0 (unsigned int) m_PrefabParentObject (file 0 path 0) (PPtr<EditorExtension>) m_PrefabInternal (file 0 path 0) (PPtr<Prefab>) m_Component (vector) size 1 (int) data (pair) first 4 (int) second (file 0 path 1163297906) (PPtr<Component>) m_Layer 0 (unsigned int) m_Name "Sakyaer" (string) m_TagString "Untagged" (string) m_Icon (file 0 path 0) (PPtr<Texture2D>) m_NavMeshLayer 0 (unsigned int) m_StaticEditorFlags 0 (unsigned int) m_IsActive 1 (bool) ID: 1163297906 (ClassID: 4) Transform m_ObjectHideFlags 0 (unsigned int) m_PrefabParentObject (file 0 path 0) (PPtr<EditorExtension>) m_PrefabInternal (file 0 path 0) (PPtr<Prefab>) m_GameObject (file 0 path 1163297905) (PPtr<GameObject>) m_LocalRotation (Quaternionf) x 0 (float) y 0 (float) z 0 (float) w 1 (float) m_LocalPosition (0 0 0) (Vector3f) m_LocalScale (1 1 1) (Vector3f) m_Children (vector) size 0 (int) m_Father (file 0 path 0) (PPtr<Transform>) m_RootOrder 0 (int)

4.Unity3D中對於每一個資原始檔都會生成對應.meta檔案,該檔案可以用記事本直接開啟;guid(全域性唯一識別符號,Globally Unique Identifier)是系統隨機生成的對資源的識別符號,guid在遊戲執行時會被用來生成一個hashid;而根據guid的前兩位0a可以在工程Library目錄下metadate(元資料)0a目錄下找到,對應的二進位制檔案,該檔案可以使用binary2text.exe開啟,得到的txt檔案,記錄了.meta檔案對應資源的所有詳細資訊。

guid: 0a4a878577c88654795d8c6aee74368d