Skip to main content

Module params

Module params 

Source
Expand description

Typed script variables. Declare them once with script_params!: they get defaults, show up as Inspector fields on the attached script, are saved in the scene and can be read or changed by other scripts (Ctx::var / Ctx::set_var).

use kvas_engine::prelude::*;
script_params! {
    /// Spins its object.
    pub struct Spinner {
        /// Degrees per second around each axis.
        speed: Vec3 = Vec3::new(0.0, 90.0, 0.0),
        enabled: bool = true,
        target: EntityRef = EntityRef::default(),
        tint: Color = Color([1.0, 0.5, 0.2, 1.0]),
        ticks: Local<u32> = Local::default(),
    }
}
let mut s = Spinner::default();
assert_eq!(s.params().len(), 4); // `Local` values are not shown

Structs§

Color
An RGBA colour variable (shown with a colour picker).
EntityRef
A reference to another object by name (shown as an object picker you can drop objects on).
Local
Script state that is not shown in the Inspector or saved.
MeshRef
A model path, picked from the project’s models.
SoundRef
A sound clip path, picked from the project’s audio files.
TextureRef
A texture path, picked from the project’s images.

Traits§

Param
A type that can be a script variable.