| Crates.io | unity-pack |
| lib.rs | unity-pack |
| version | 0.1.0 |
| created_at | 2025-12-22 23:38:33.313916+00 |
| updated_at | 2025-12-22 23:38:33.313916+00 |
| description | Create Unity .unitypackage files and assets from Rust |
| homepage | |
| repository | https://github.com/Autarkis/unity-pack-rs |
| max_upload_size | |
| id | 2000482 |
| size | 108,560 |
Create Unity .unitypackage files from Rust.
Unity packages are typically created from within the Unity Editor, but sometimes you need to generate them programmatically:
use unity_pack::{UnityPackage, Asset};
fn main() -> unity_pack::Result<()> {
UnityPackage::builder()
.asset(Asset::text("Assets/Config/settings.json", r#"{"volume": 0.8}"#))
.asset(Asset::binary("Assets/Data/heightmap.raw", include_bytes!("terrain.raw").to_vec()))
.build()?
.save("my-assets.unitypackage")?;
Ok(())
}
[dependencies]
unity-pack = "0.1"
| Feature | Description |
|---|---|
scriptable |
Generate Unity ScriptableObject YAML files |
terrain |
Heightmap conversion helpers (f32 → 16/32-bit raw) |
tui |
Interactive terminal UI for package creation |
unity-pack = { version = "0.1", features = ["scriptable", "terrain"] }
.meta files with proper GUIDsuse unity_pack::{UnityPackage, Asset};
let mut pkg = UnityPackage::new();
// From raw data
pkg.add(Asset::binary("Assets/Textures/noise.raw", vec![0u8; 1024]))?;
pkg.add(Asset::text("Assets/Scripts/Player.cs", "using UnityEngine;"))?;
pkg.add(Asset::folder("Assets/Levels"))?;
// From files on disk
pkg.add(Asset::from_file("Assets/Models/tree.fbx", "./exports/tree.fbx")?)?;
pkg.save("game-assets.unitypackage")?;
use unity_pack::scriptable::{ScriptableObject, vec3, color};
use unity_pack::UnityGuid;
let script_guid = UnityGuid::from_hex("0123456789abcdef0123456789abcdef")?;
let config = ScriptableObject::new("PlayerConfig")
.script(script_guid)
.field("maxHealth", 100)
.field("walkSpeed", 5.5)
.field("spawnPoint", vec3(10.0, 0.0, 20.0))
.field("teamColor", color(1.0, 0.0, 0.0, 1.0));
let asset = config.to_asset("Assets/Config/PlayerConfig.asset");
use unity_pack::terrain::heightmap_16bit;
let heights: Vec<f32> = generate_terrain(256, 256); // 0.0 - 1.0 range
let asset = heightmap_16bit("Assets/Terrain/heightmap.raw", &heights, 256, 256);
cargo install unity-pack --features tui
unity-pack
Navigate your filesystem, select files, and create packages interactively.
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
Full API documentation is available on docs.rs.
Contributions are welcome! Please feel free to open an issue or submit a pull request.
Enable pre-commit hooks (runs fmt + clippy before each commit):
git config core.hooksPath .githooks
See CHANGELOG.md for release history.
MIT