IntegerControl.cs 940 B

123456789101112131415161718192021222324252627282930313233
  1. using UnityEngine.InputSystem.LowLevel;
  2. ////TODO: this or the layout system needs to detect when the format isn't supported by the control
  3. namespace UnityEngine.InputSystem.Controls
  4. {
  5. /// <summary>
  6. /// A generic input control reading integer values.
  7. /// </summary>
  8. [Scripting.Preserve]
  9. public class IntegerControl : InputControl<int>
  10. {
  11. /// <summary>
  12. /// Default-initialize an integer control.
  13. /// </summary>
  14. public IntegerControl()
  15. {
  16. m_StateBlock.format = InputStateBlock.FormatInt;
  17. }
  18. /// <inheritdoc/>
  19. public override unsafe int ReadUnprocessedValueFromState(void* statePtr)
  20. {
  21. return m_StateBlock.ReadInt(statePtr);
  22. }
  23. /// <inheritdoc/>
  24. public override unsafe void WriteValueIntoState(int value, void* statePtr)
  25. {
  26. m_StateBlock.WriteInt(statePtr, value);
  27. }
  28. }
  29. }