livemod-derive

Crates.iolivemod-derive
lib.rslivemod-derive
version0.5.0
sourcesrc
created_at2021-06-24 02:48:17.089086
updated_at2021-10-02 05:23:37.096871
descriptionDerive macro for livemod
homepage
repositoryhttps://github.com/TheOnlyMrCat/LiveMod
max_upload_size
id414227
size20,811
(TheOnlyMrCat)

documentation

README

LiveMod - Runtime modification of program values

livemod-test livemod-gui crates.io dependency status

Livemod is my attempt to make Unity-style runtime parameter modification possible in Rust, in a way that is simple and easy to turn off if necessary.

Usage

Livemod requires the library, livemod, and a locally-installed viewer, such as livemod-gui.

livemod-gui can be installed through cargo:

cargo install livemod-gui

And can be used from your code by:

let livemod = LiveModHandle::new_gui();

let tracked_variable = livemod.create_variable("My variable", 0_u32);

Using #[derive]

The LiveMod trait can be #[derive]d if the feature derive is enabled. The behaviour of the derive macro can be modified with the #[livemod] field attribute, the behaviour of which is documented below:

#[livemod(skip)]: Skip representing a field

The field will not be modifiable by livemod, and will not be required to implement the LiveMod trait.

#[livemod(rename = "New name")] Rename a field

The field will be labelled with the new name. By default, a field's label is generated by capitalising the first letter of its name and replacing underscores with spaces.

#[livemod(repr = Trait(args))] Change the representation of a field

Instead of calling LiveMod::data_type() on the field's type to determine its representation, use its definition of the supplied trait instead.

For example, integers and floats implement the Slider trait, and can be used as follows:

#[livemod(repr = Slider(0..=100))]
field: u32
Commit count: 61

cargo fmt