KeyLongPressSetOrigin.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using SC.XR.Unity.Module_InputSystem;
  5. public class KeyLongPressSetOrigin : MonoBehaviour
  6. {
  7. public enum SetOriginType {
  8. Head,
  9. World,
  10. Other,
  11. }
  12. public SetOriginType setOriginType = SetOriginType.Head;
  13. // Start is called before the first frame update
  14. void Start()
  15. {
  16. DispatcherBase.KeyLongDelegateRegister(AnyKeyEventDelegate);
  17. }
  18. // Update is called once per frame
  19. void Update()
  20. {
  21. }
  22. void OnDestroy() {
  23. DispatcherBase.KeyLongDelegateUnRegister(AnyKeyEventDelegate);
  24. }
  25. void AnyKeyEventDelegate(InputKeyCode keyCode, InputDevicePartBase part) {
  26. if (setOriginType == SetOriginType.Head) {
  27. if (keyCode == InputKeyCode.Enter && part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject) {
  28. API_GSXR_Slam.GSXR_Set_HeadOrigin(part.inputDataBase.SCPointEventData.pointerCurrentRaycast.worldPosition);
  29. }
  30. } else if (setOriginType == SetOriginType.World) {
  31. if (keyCode == InputKeyCode.Enter && part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject) {
  32. API_GSXR_Slam.GSXR_Set_WorldOrigin(part.inputDataBase.SCPointEventData.pointerCurrentRaycast.worldPosition);
  33. }
  34. }
  35. }
  36. }