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
- Unity 6000.2 or later
- R3 (must be installed manually)
- Optionally supports Dependency Injection
- Install R3 in your project.
- Add the package from Git:
https://github.com/Urkidi/UnityInputToObservable.git?path=/Assets/UnityInputToObservable/
- Create two enums in your project:
public enum ActionMapType
{
[StringRepresentation("Player")]
Player
}
public enum ActionType
{
[StringRepresentation("Move")]
Move,
[StringRepresentation("Action")]
Action
}- The enums string representation must match the InputAction.assets map and action entries.
- Create a InputActions.asset.
- Populate the asset with your actions.
- Create a PlayerInputConfig and add the InputActions.asset to it..
services.AddUnityInputToObservable<ActionMapType, ActionType>();Add to the DI the IPlayerInputConfig implementation.
- Access IInputCollectionModel where needed.
- From the collection model access the specific IInputModel by providing the right ActionMapType.
- Once accessed the model, subscribe to the desired input event.