暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OnScreenButton.cs 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI
  2. using System;
  3. using UnityEngine.EventSystems;
  4. using UnityEngine.InputSystem.Layouts;
  5. ////TODO: custom icon for OnScreenButton component
  6. namespace UnityEngine.InputSystem.OnScreen
  7. {
  8. /// <summary>
  9. /// A button that is visually represented on-screen and triggered by touch or other pointer
  10. /// input.
  11. /// </summary>
  12. [AddComponentMenu("Input/On-Screen Button")]
  13. [HelpURL(InputSystem.kDocUrl + "/manual/OnScreen.html#on-screen-buttons")]
  14. public class OnScreenButton : OnScreenControl, IPointerDownHandler, IPointerUpHandler
  15. {
  16. public void OnPointerUp(PointerEventData eventData)
  17. {
  18. SendValueToControl(0.0f);
  19. }
  20. public void OnPointerDown(PointerEventData eventData)
  21. {
  22. SendValueToControl(1.0f);
  23. }
  24. ////TODO: pressure support
  25. /*
  26. /// <summary>
  27. /// If true, the button's value is driven from the pressure value of touch or pen input.
  28. /// </summary>
  29. /// <remarks>
  30. /// This essentially allows having trigger-like buttons as on-screen controls.
  31. /// </remarks>
  32. [SerializeField] private bool m_UsePressure;
  33. */
  34. [InputControl(layout = "Button")]
  35. [SerializeField]
  36. private string m_ControlPath;
  37. protected override string controlPathInternal
  38. {
  39. get => m_ControlPath;
  40. set => m_ControlPath = value;
  41. }
  42. }
  43. }
  44. #endif