Skip to main content

Script

Trait Script 

Source
pub trait Script {
    // Provided methods
    fn start(&mut self, _ctx: &mut Ctx<'_>) { ... }
    fn update(&mut self, _ctx: &mut Ctx<'_>) { ... }
    fn fixed_update(&mut self, _ctx: &mut Ctx<'_>) { ... }
    fn fields(&mut self) -> Vec<Field<'_>> { ... }
}
Expand description

Implement this (plus Default) and list the type in register_scripts!. Public fields are exposed in the editor by returning them from fields().

Provided Methods§

Source

fn start(&mut self, _ctx: &mut Ctx<'_>)

Called once before this instance’s first gameplay callback. A hot reload creates a new instance and calls start again.

Source

fn update(&mut self, _ctx: &mut Ctx<'_>)

Called once per accepted simulation frame before fixed physics steps.

Source

fn fixed_update(&mut self, _ctx: &mut Ctx<'_>)

Called before every fixed physics step (60 Hz by default). Apply forces here.

Source

fn fields(&mut self) -> Vec<Field<'_>>

Editable/persistent properties. Missing saved properties retain defaults.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§