Expand description
UnityEngine.Input (the legacy input manager).
Poll it from on_update, once per frame:
use hao_il2cpp_unity::{input, on_update, time, KeyCode};
on_update(|| {
// F2 toggles slow motion.
if input::key_down(KeyCode::F2).unwrap_or(false) {
let scale = time::scale().unwrap_or(1.0);
let _ = time::set_scale(if scale < 1.0 { 1.0 } else { 0.25 });
}
})?;Functionsยง
- input_
string - The characters typed this frame (including
\bfor backspace and\rfor return), for driving a text field. - key
- Whether
keyis held this frame. - key_
down - Whether
keywas pressed this frame. - key_up
- Whether
keywas released this frame. - mouse_
button - Whether mouse
button(0 left, 1 right, 2 middle) is held. - mouse_
position - The cursor position in pixels, origin at the bottom left.
- scroll_
delta - The scroll wheel movement this frame (
xhorizontal,yvertical).