暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AnyKeyControl.cs 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using UnityEngine.InputSystem.Layouts;
  2. using UnityEngine.InputSystem.LowLevel;
  3. ////REVIEW: generalize this to AnyButton and add to more devices?
  4. namespace UnityEngine.InputSystem.Controls
  5. {
  6. /// <summary>
  7. /// A control that simply checks the entire state it's been assigned
  8. /// for whether there's any non-zero bytes. If there are, the control
  9. /// returns 1.0; otherwise it returns 0.0.
  10. /// </summary>
  11. /// <remarks>
  12. /// This control is used by <see cref="Keyboard.anyKey"/> to create a button
  13. /// that is toggled on as long as any of the keys on the keyboard is pressed.
  14. /// </remarks>
  15. /// <seealso cref="Keyboard.anyKey"/>
  16. [InputControlLayout(hideInUI = true)]
  17. public class AnyKeyControl : ButtonControl
  18. {
  19. ////TODO: wasPressedThisFrame and wasReleasedThisFrame
  20. /// <summary>
  21. /// Default initialization. Sets state size to 1 bit and format to
  22. /// <see cref="InputStateBlock.FormatBit"/>.
  23. /// </summary>
  24. public AnyKeyControl()
  25. {
  26. m_StateBlock.sizeInBits = 1; // Should be overridden by whoever uses the control.
  27. m_StateBlock.format = InputStateBlock.FormatBit;
  28. }
  29. /// <inheritdoc />
  30. public override unsafe float ReadUnprocessedValueFromState(void* statePtr)
  31. {
  32. return this.CheckStateIsAtDefault(statePtr) ? 0.0f : 1.0f;
  33. }
  34. }
  35. }