Skip to main content

Module input

Module input 

Source
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 \b for backspace and \r for return), for driving a text field.
key
Whether key is held this frame.
key_down
Whether key was pressed this frame.
key_up
Whether key was 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 (x horizontal, y vertical).