How to Optimize GLB Files for Unity with glTFast
Choose safe compression settings, install the right Unity decoder packages, and avoid materials or models disappearing in player builds.
Unity's glTFast importer can handle efficient modern glTF assets, but optional compression is not self-contained magic. Draco, Meshopt, and KTX2 each require the matching Unity package and platform-capable native or Burst implementation. Build the asset and the player configuration together, and treat an Editor preview as only the first test.
Start with the maintained Unity package
For current projects, use the Unity-maintained package identifiercom.unity.cloud.gltfast and follow the installation guidance for the Unity version you ship. Pin the package version in the project manifest and review its release notes before changing the asset preset. A model produced for a newer decoder or extension can fail even when an older glTFast version imports the uncompressed source.
Choose the delivery form deliberately
GLB is usually the safer runtime, Addressables, or downloadable-content unit because buffers and images travel with one file. JSON glTF is still useful when resources should be separately cached or replaced, but the JSON, .bin buffers, and images must remain at their referenced relative locations. A custom download provider must resolve and report failures for every dependency, not just the first JSON request.
A safe OptimizeGLB preset for Unity
- Enable pruning and deduplication.
- Keep simplification off until silhouettes and animation are reviewed.
- Preserve normals, tangents, skins, morph targets, and animation data.
- Use JPEG or PNG textures for the initial compatibility build.
- Leave Draco, Meshopt, and KTX2 disabled in the baseline.
Create this rollback-friendly output with OptimizeGLB. Test it in a development player before introducing optional codecs. The clean baseline helps distinguish an asset defect from a missing runtime package or platform build issue.
Install a decoder before requiring its extension
A Draco-compressed mesh needs Unity's Draco package, a Meshopt-compressed mesh needs the Meshopt package, and a KTX2/Basis texture needs the KTX package. Add and verify the corresponding optional dependency before distributing an asset that marks the extension as required. Otherwise glTFast cannot fall back to geometry or image data that the GLB no longer contains.
Add one codec at a time. Geometry compression primarily reduces download and storage bytes; it can add decode work and does not reduce the final triangle count, material count, or decoded mesh memory. KTX2 can improve texture transfer and GPU formats, but output depends on the target GPU and transcoder path. WebP is not the safest default for the documented glTFast Unity pipeline, so keep JPEG/PNG unless the exact package and platform combination has been proven.
Test runtime import with useful diagnostics
Load the asset through the same API and URI used by the product, await the import result, and present a clear error when it fails. During development, attach glTFast's console logger so unsupported extensions, missing resources, and material conversion warnings are visible. For remote content, separately handle HTTP failure, cancellation, decode failure, and instantiation failure instead of leaving an empty GameObject.
Protect shaders in player builds
Runtime-imported materials can appear correctly in the Editor and then render pink or incorrectly in a player if the required shader variants were stripped. Follow glTFast's material and shader guidance for the selected render pipeline, include the needed variants, and test a clean build. Repeat the test for Built-in, URP, or HDRP whenever the project's rendering configuration changes.
Verify every target platform
Desktop Editor success does not guarantee WebGL, iOS, Android, console, or an AOT build has the same codec implementation and memory behavior. Test a cold runtime load on each supported target. Check coordinate and unit conversion, normals and tangents, alpha materials, skinning, morph targets, animation clips, and the lifetime of instantiated resources. Dispose downloaded assets intentionally when a large catalog rotates.
Unity release checklist
- Pin the glTFast and optional decoder package versions.
- Validate the optimized GLB before adding it to the project.
- Test the same runtime URL or Addressables path used in production.
- Build a player and verify materials, animation, and error handling.
- Profile transfer, decode time, peak memory, and frame time separately.
- Repeat codec testing on every supported platform and graphics API.
Related official resources
These links point to the maintainers' current documentation, source repositories, or validation tools rather than third-party summaries.
- Unity glTFast repository: the maintained package source, releases, and issue tracker.
- glTFast package overview: features, dependencies, and supported workflows.
- glTFast installation: official package and optional dependency setup.
- glTFast runtime import: runtime loading, logging, instantiation, and download APIs.
- glTFast runtime export: the maintained runtime export workflow and boundaries.
- Khronos UnityGLTF: the Khronos-supported alternative Unity glTF implementation.