Wukuro
Wukuro is an event scripting framework for Unity based on WaaS. In-game events such as conversations, cutscenes and branches are written in Rust and run on Unity as WebAssembly components.
Wukuro is very experimental and breaking changes can be made.
Features
- Write events in Rust: events can be written with the features of the language as they are, such as conditions, loops and functions for common processes.
- Multiple entry points in a file: a function with
#[entry]becomes an entry point. Constants and functions in the same file can be shared by multiple events. - Arguments set in the inspector: objects in the scene and assets can be passed to the arguments of entry points from the Unity inspector. The types of the objects can also be constrained.
- Designed to be extended for each game: Wukuro itself provides only basic features such as waiting, variables, logging and dialogs. Game-specific features such as camera, sound and items are added by the game as C# interfaces.
Components
Wukuro consists of a Unity package and Rust crates.
| Name | Kind | Contents |
|---|---|---|
com.ruccho.wukuro | Unity package | Running scripts, references to entry points, the inspector, and the host implementations of wukuro:core and wukuro:dialog |
wukuro | Rust crate | Bindings of wukuro:core, #[entry], and helpers for texts and object types |
wukuro-macro | Rust crate | Procedural macros used by wukuro |
wukuro-dialog | Rust crate | Bindings of wukuro:dialog and helpers to show messages |
The functions and types between the host and scripts are defined as WIT packages of the Component Model.
wukuro:core: basic features such as the context, arguments, variables, waiting and textswukuro:dialog: showing dialogs (messages, options and fades)
Game-specific features are added as your own WIT packages in the same way (Extending).
Installation
Requirements
Tutorial
In this tutorial, we create a simple script that only outputs logs and run it from a component in the scene. Complete Installation beforehand.
Writing Scripts
Entry points
Running Scripts
References to entry points
Extending
Wukuro itself provides only basic features such as waiting, variables, logging and dialogs. Game-specific features such as playing sounds, controlling the camera and giving items are expected to be added by the game.
Object Types
Any UnityEngine.Object can be passed to a parameter &Object of an entry point. When the type of the parameter is &ObjectOf, the inspector accepts only objects of type T. The types are defined starting from C#.
WIT Reference
The functions and types between the host of Wukuro and scripts are defined as the following WIT packages. The WIT is generated from the C# definitions in Definitions/ of the Unity package and included in wit/ of each crate.