Bevy game-logic crates to Unity viauniti
A Rust cdylib that exposes the KBVE Bevy game-logic crates — pathfinder, inventory, battle, skills — to the Unity runtime used by RareIcon, through generated csbindgen C# bindings.
Four crates in one dylib
uniti compiles as a cdylib and is loaded by Unity as a native plugin, bundling the KBVE Bevy game-logic crates plus two runtime helpers so Unity needs nothing on the host.
- Logic — bevy_pathfinder, bevy_inventory, bevy_battle, bevy_skills.
- Helpers — bundled rusqlite + pure-Rust zstd.
What it gives you
Features
Bundles game-logic crates
Bundles bevy_pathfinder, bevy_inventory, bevy_battle, and bevy_skills into a single native plugin.
Generated C# bindings
build.rs invokes csbindgen at build time to write the C# wrapper Uniti.g.cs into the Unity project.
No host dependencies
Statically bundles rusqlite (bundled feature) and pure-Rust zstd, so Unity loads the dylib without host libraries.
Per-platform Nx builds
Nx targets build the release cdylib and copy it into the Unity Plugins tree for macOS, Windows, and Linux.
The bridge
Overview
Crates & build
Bundled crates, build & bindings
Bundled Crates
Section titled “Bundled Crates”| Crate | Purpose |
|---|---|
bevy_pathfinder | Grid flow-field navigation + chokepoint detection |
bevy_inventory | Item / slot persistence |
bevy_battle | Combat resolution |
bevy_skills | Skill / proc tables |
Plus two runtime helpers compiled into the dylib so Unity does not need them on the host:
rusqlitewith thebundledfeature — save-archive persistence, no systemlibsqlite3dep.zstdwith default features disabled — pure-Rust compression for save blobs.
Build Targets
Section titled “Build Targets”Each Nx target builds the release cdylib and copies it into the Unity Plugins/ tree for the matching platform.
npx nx run uniti:build:macosnpx nx run uniti:build:windowsnpx nx run uniti:build:linuxnpx nx run uniti:build:allOn macOS the target also runs xattr -cr and an adhoc codesign --force --deep --sign - so the dylib loads through Gatekeeper without a quarantine prompt.
Generated Bindings
Section titled “Generated Bindings”build.rs invokes csbindgen and writes the C# wrapper to:
apps/rareicon/unity-rareicon/Assets/_RareIcon/Scripts/Native/Uniti.g.csHand-written wrapper classes live alongside it under Native/Wrappers/ (for example NativeWorld).
Tracked in the dispatch manifest under the crates pipeline. The standard test / lint nx targets are wired:
npx nx run uniti:testnpx nx run uniti:lintLicense
Section titled “License”MIT
Questions
Frequently asked
What is the uniti crate?
uniti is the C FFI bridge that exposes the KBVE Bevy game-logic crates to the Unity runtime used by RareIcon. It compiles as a cdylib and is loaded by Unity as a native plugin, bundling bevy_pathfinder, bevy_inventory, bevy_battle, and bevy_skills.
How are the C# bindings generated?
build.rs invokes csbindgen at build time to generate a C# wrapper (Uniti.g.cs) that is committed into the Unity project under Assets/_RareIcon/Scripts/Native. Hand-written wrapper classes such as NativeWorld live alongside it under Native/Wrappers.
Does uniti need system libraries on the host?
No. It statically bundles rusqlite with the bundled feature (so no system libsqlite3 is required) and zstd with default features disabled for pure-Rust save-blob compression, so Unity can load the dylib without host dependencies.
