Appearance
Understanding Unity WebGL's .data
File and Options for Parsing
When developing games with Unity for WebGL deployment, you might notice a .data
file generated alongside your build. This file plays a crucial role in how your game functions in a web environment. So, what exactly is the .data
file, and what format does it use?
The Role and Format of the .data
File
The .data
file in a Unity WebGL build is a proprietary binary file that Unity creates to package all the essential resources your game needs at runtime. This includes scenes, assets, textures, audio, and compiled scripts. Here are some key points about the .data
file:
- Binary Format: It's a binary file, meaning it's not human-readable and is optimized for machine interpretation.
- Resource Packaging: Unity consolidates all game resources into this single file to streamline the loading process in web browsers.
- Optimized Loading: By packaging resources this way, Unity reduces the number of HTTP requests needed, improving load times and performance.
- Integration with WebGL Runtime: The Unity WebGL runtime scripts (
UnityLoader.js
or newer versions with*.framework.js
and*.wasm
files) handle the loading and interpretation of the.data
file during game execution.
Extract Resources from Unity .data
File
Tools
- UABE with wasm support can extract the .data build ouput (the extrating result cotainers
data.unity3d
andglobal-metadata.dat
files) - use AssetRipper to extract the resources from
data.unity3d
andglobal-metadata.dat
(AssetRipper also allows you to extract unity resources from androind apk directly!)
Python script
This is not a good option
UnityPack can parse .data file, and from them, obtain data.unity3d file. It supports parsing older versions of .unity3d files, allowing you to extract images, sounds, meshes, and other resources. However, UnityPack is no longer maintained. For newer versions of Unity, you can use UnityPy to parse data.unity3d files.