unity-pack
Create Unity .unitypackage files from Rust.
Why?
Unity packages are typically created from within the Unity Editor, but sometimes you need to generate them programmatically:
- CI/CD pipelines - Automate asset packaging without opening Unity
- Procedural generation - Export terrain, textures, or configs from external tools
- Asset pipelines - Build Unity packages from non-Unity source data
Quick Start
use ;
Installation
[]
= "0.1"
Optional Features
| Feature | Description |
|---|---|
scriptable |
Generate Unity ScriptableObject YAML files |
terrain |
Heightmap conversion helpers (f32 → 16/32-bit raw) |
tui |
Interactive terminal UI for package creation |
= { = "0.1", = ["scriptable", "terrain"] }
Features
- Generate valid Unity
.metafiles with proper GUIDs - Support for binary assets, text assets, and folders
- Deterministic GUIDs for reproducible builds
- Builder pattern API
- Load assets directly from files on disk
Examples
Adding Assets
use ;
let mut pkg = new;
// From raw data
pkg.add?;
pkg.add?;
pkg.add?;
// From files on disk
pkg.add?;
pkg.save?;
ScriptableObject Generation
use ;
use UnityGuid;
let script_guid = from_hex?;
let config = new
.script
.field
.field
.field
.field;
let asset = config.to_asset;
Terrain Heightmaps
use heightmap_16bit;
let heights: = generate_terrain; // 0.0 - 1.0 range
let asset = heightmap_16bit;
Interactive TUI
Navigate your filesystem, select files, and create packages interactively.
Unity Package Format
A .unitypackage is a gzipped tar archive containing one directory per asset:
<GUID>/
├── pathname # Unity path (e.g., "Assets/Data/file.raw")
├── asset # File contents
└── asset.meta # Unity metadata
Requirements
- Rust 1.70+
API Documentation
Full API documentation is available on docs.rs.
Contributing
Contributions are welcome! Please feel free to open an issue or submit a pull request.
Development Setup
Enable pre-commit hooks (runs fmt + clippy before each commit):
See CHANGELOG.md for release history.
License
MIT