Expand description
Unity Asset Parser
A comprehensive Rust library for parsing Unity asset files, supporting both YAML and binary formats.
This crate provides high-performance, memory-safe parsing of Unity files while maintaining exact compatibility with Unity’s formats.
§Features
- YAML Processing: Complete Unity YAML format support with multi-document parsing
- Binary Assets: AssetBundle and SerializedFile parsing with compression support
- Async Support: Optional async/await API for concurrent processing (enable with
async
feature) - Type Safety: Rust’s type system prevents common parsing vulnerabilities
- Performance: Zero-cost abstractions and memory-efficient parsing
§Examples
§Basic YAML Processing
use unity_asset::{YamlDocument, UnityDocument};
// Load a Unity YAML file
let doc = YamlDocument::load_yaml("ProjectSettings.asset", false)?;
// Access and filter objects
let settings = doc.get(Some("PlayerSettings"), None)?;
println!("Product name: {:?}", settings.get("productName"));
§Binary Asset Processing
use unity_asset::load_bundle_from_memory;
// Load and parse AssetBundle
let data = std::fs::read("game.bundle")?;
let bundle = load_bundle_from_memory(data)?;
// Process assets
for asset in &bundle.assets {
println!("Found asset with {} objects", asset.object_count());
}
§Async Processing (requires async
feature)
use unity_asset::{YamlDocument, AsyncUnityDocument};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load file asynchronously
let doc = YamlDocument::load_yaml_async("ProjectSettings.asset", false).await?;
// Same API as sync version
let settings = doc.get(Some("PlayerSettings"), None)?;
println!("Product name: {:?}", settings.get("productName"));
Ok(())
}
Modules§
- class_
ids - Common Unity class IDs
- class_
names - Common Unity class names
- environment
- Environment for managing multiple Unity assets
Structs§
- Asset
Bundle - A Unity AssetBundle
- GLOBAL_
CLASS_ ID_ MAP - Global class ID map instance
- Serialized
File - Complete SerializedFile structure
- Unity
Class - A Unity class instance
- Unity
Class IdMap - Unity class ID to name mapping This is a global registry that maps class IDs to class names
- Unity
Class Registry - Registry for Unity class types
- Yaml
Document - A Unity YAML document containing one or more Unity objects
Enums§
- Document
Format - Supported Unity document formats
- Line
Ending - Line ending types
- Unity
Asset Error - Main error type for Unity asset parsing operations
- Unity
Value - A Unity value that can be stored in a Unity class
Constants§
- UNITY_
TAG_ URI - Unity YAML tag URI
- UNITY_
YAML_ VERSION - Unity YAML version
Traits§
- Unity
Document - Abstract trait for Unity documents
Functions§
- load_
bundle - Convenience functions for quick bundle loading Load a single bundle from file
- load_
bundle_ from_ memory - Load a bundle from memory
- load_
bundle_ with_ options - Load a bundle with specific options
Type Aliases§
- Result
- Result type alias for Unity asset operations