pub struct AnimatorController {
pub states: HashMap<String, AnimationState>,
pub transitions: Vec<Transition>,
pub params: HashMap<String, ParamValue>,
pub layers: Vec<AnimationLayer>,
pub clips: HashMap<String, AnimationClip>,
/* private fields */
}Expand description
Drives one or more AnimationLayers with shared parameter space.
Fields§
§states: HashMap<String, AnimationState>§transitions: Vec<Transition>§params: HashMap<String, ParamValue>§layers: Vec<AnimationLayer>§clips: HashMap<String, AnimationClip>Clip library for fetching clips by name.
Implementations§
Source§impl AnimatorController
impl AnimatorController
pub fn new() -> Self
pub fn add_state(&mut self, state: AnimationState)
pub fn add_clip(&mut self, clip: AnimationClip)
pub fn add_transition(&mut self, t: Transition)
pub fn add_layer(&mut self, layer: AnimationLayer)
pub fn set_float(&mut self, name: &str, v: f32)
pub fn set_bool(&mut self, name: &str, v: bool)
pub fn set_int(&mut self, name: &str, v: i32)
Sourcepub fn set_trigger(&mut self, name: &str)
pub fn set_trigger(&mut self, name: &str)
Set a trigger (one-shot bool that resets after being consumed).
pub fn get_float(&self, name: &str) -> f32
pub fn get_bool(&self, name: &str) -> bool
pub fn start(&mut self, state_name: &str)
pub fn start_layer(&mut self, layer_name: &str, state_name: &str)
Sourcepub fn tick(&mut self, dt: f32) -> AnimationOutput
pub fn tick(&mut self, dt: f32) -> AnimationOutput
Advance all layers by dt seconds and evaluate transitions.
Returns blended output across all layers.
Sourcepub fn drain_events(&mut self) -> Vec<FiredEvent>
pub fn drain_events(&mut self) -> Vec<FiredEvent>
Drain all fired animation events since last call.
Sourcepub fn play(&mut self, state_name: &str)
pub fn play(&mut self, state_name: &str)
Force the base layer into a specific state immediately.
Sourcepub fn cross_fade(&mut self, state_name: &str, duration: f32)
pub fn cross_fade(&mut self, state_name: &str, duration: f32)
Cross-fade to a state over duration seconds.
Sourcepub fn normalized_time(&self) -> f32
pub fn normalized_time(&self) -> f32
Current normalized time of the base layer’s active state.
Sourcepub fn current_state(&self) -> Option<&str>
pub fn current_state(&self) -> Option<&str>
Name of the currently active state on the base layer.
Sourcepub fn is_transitioning(&self) -> bool
pub fn is_transitioning(&self) -> bool
Whether the base layer is transitioning.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AnimatorController
impl RefUnwindSafe for AnimatorController
impl Send for AnimatorController
impl Sync for AnimatorController
impl Unpin for AnimatorController
impl UnsafeUnpin for AnimatorController
impl UnwindSafe for AnimatorController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.