Skip to content

Input (Unity Input System)

LoL Engine does not provide an IInputService or input wrapper. The engine-level Input Service was removed before 1.0 — see CHANGELOG.md (it hard-coded game-specific action maps and UI handlers). Use Unity's Input System package directly in your game assemblies.


Install

  1. Window → Package Manager → install Input System (com.unity.inputsystem).
  2. When prompted, choose how the project handles UI/input (Input System package settings).

LoL Engine does not declare com.unity.inputsystem in package.json — it is an optional game dependency.


Starter Asset (Optional)

The package ships a reference .inputactions file you can duplicate or extend:

Assets/LoLEngine/Runtime/Resources/Input/DefaultInputSystem_Actions.inputactions

Load it at runtime or assign it to a PlayerInput component in your scenes. Define your own action maps and bindings for your game; do not rely on engine code to enable maps.


using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    [SerializeField] private InputActionAsset actions;
    private InputAction _move;
    private InputAction _jump;

    void OnEnable()
    {
        var player = actions.FindActionMap("Player", throwIfNotFound: true);
        _move = player.FindAction("Move", throwIfNotFound: true);
        _jump = player.FindAction("Jump", throwIfNotFound: true);
        _jump.performed += OnJump;
        player.Enable();
    }

    void OnDisable()
    {
        _jump.performed -= OnJump;
        actions.Disable();
    }

    void Update()
    {
        Vector2 move = _move.ReadValue<Vector2>();
        // apply movement
    }

    void OnJump(InputAction.CallbackContext ctx) { /* jump */ }
}

Use ServiceAwaiter for engine services (IAudioService, ISaveSystem, etc.). Input actions are independent of ServiceLocator.


Demo Scenes and UI

Bundled sample scenes (Samples~/) use uGUI buttons and Unity's EventSystem for clicks. They do not require the Input System package to run the audio, save, pool, or localization demos.

If your project uses the new Input System for UI, ensure each scene's EventSystem has the matching Input Module (e.g. InputSystemUIInputModule vs StandaloneInputModule).


Further Reading