| #if MLA_INPUT_SYSTEM |
| using Unity.MLAgents.Actuators; |
| using UnityEngine.InputSystem; |
| using UnityEngine.InputSystem.LowLevel; |
|
|
| namespace Unity.MLAgents.Input |
| { |
| |
| |
| |
| [UnityEngine.Scripting.APIUpdating.MovedFrom("Unity.MLAgents.Extensions.Input")] |
| public class IntegerInputActionAdaptor : IRLActionInputAdaptor |
| { |
| |
| |
| public ActionSpec GetActionSpecForInputAction(InputAction action) |
| { |
| return ActionSpec.MakeDiscrete(2); |
| } |
|
|
| |
| public void WriteToInputEventForAction(InputEventPtr eventPtr, InputAction action, InputControl control, ActionSpec actionSpec, in ActionBuffers actionBuffers) |
| { |
| var val = actionBuffers.DiscreteActions[0]; |
| control.WriteValueIntoEvent(val, eventPtr); |
| } |
|
|
| |
| public void WriteToHeuristic(InputAction action, in ActionBuffers actionBuffers) |
| { |
| var actions = actionBuffers.DiscreteActions; |
| var val = action.ReadValue<int>(); |
| actions[0] = val; |
| } |
| } |
| } |
| #endif // MLA_INPUT_SYSTEM |
|
|