Skip to content

Urkidi/UnityInputToObservable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity Input To Observable

Transforms Unity's Input System into observable streams using R3.

  • Package https://github.com/Urkidi/UnityInputToObservable.git?path=/Assets/UnityInputToObservable/
  • Dependency injection subpackage https://github.com/Urkidi/UnityInputToObservable.git?path=/Assets/UnityInputToObservable.DependencyInjection
  • Sample subpackage https://github.com/Urkidi/UnityInputToObservable.git?path=/Assets/UnityInputToObservable.Sample

Requirements

  • Unity 6000.2 or later
  • R3 (must be installed manually)
  • Optionally supports Dependency Injection

Setup

  1. Install R3 in your project.
  2. Add the package from Git:

https://github.com/Urkidi/UnityInputToObservable.git?path=/Assets/UnityInputToObservable/

  1. Create two enums in your project:
public enum ActionMapType 
{
    [StringRepresentation("Player")]
    Player
}

public enum ActionType 
{
    [StringRepresentation("Move")]
    Move,
    [StringRepresentation("Action")]
    Action
}
  1. The enums string representation must match the InputAction.assets map and action entries.
  2. Create a InputActions.asset.
  3. Populate the asset with your actions.
  4. Create a PlayerInputConfig and add the InputActions.asset to it..

Installing into DI:

services.AddUnityInputToObservable<ActionMapType, ActionType>();

Add to the DI the IPlayerInputConfig implementation.

Usage

  1. Access IInputCollectionModel where needed.
  2. From the collection model access the specific IInputModel by providing the right ActionMapType.
  3. Once accessed the model, subscribe to the desired input event.

About

Transforms Unity's Input System into observable streams using R3.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages