InputDeviceHandPartUI.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Collections;
  2. using UnityEngine;
  3. namespace SC.XR.Unity.Module_InputSystem.InputDeviceHand {
  4. public class InputDeviceHandPartUI : InputDevicePartUIBase {
  5. public InputDeviceHandPart inputDeviceHandPart {
  6. get {
  7. return inputDevicePartBase as InputDeviceHandPart;
  8. }
  9. }
  10. public ModelHand modelHand {
  11. get {
  12. return modelBase as ModelHand;
  13. }
  14. }
  15. HandMenu _handMenu;
  16. public HandMenu handMenu {
  17. get {
  18. if(_handMenu == null) {
  19. _handMenu = GetComponentInChildren<HandMenu>(true);
  20. }
  21. return _handMenu;
  22. }
  23. }
  24. public override void OnSCAwake() {
  25. base.OnSCAwake();
  26. AddModule(handMenu);
  27. }
  28. //public override void OnSCStart() {
  29. // base.OnSCStart();
  30. // handMenu.ModuleStart();
  31. //}
  32. Vector3 handHead;
  33. float angle = 0;
  34. public override void OnSCLateUpdate() {
  35. base.OnSCLateUpdate();
  36. if(inputDeviceHandPart && API_GSXR_Slam.SlamManager) {
  37. handHead = API_GSXR_Slam.SlamManager.head.position - inputDeviceHandPart.inputDataHand.handInfo.centerPosition;
  38. angle = Vector3.Angle(handHead, inputDeviceHandPart.inputDataHand.handInfo.normal);
  39. if(angle < 30) {
  40. if(handMenu && handMenu.IsModuleStarted == false) {
  41. handMenu.ModuleStart();
  42. }
  43. } else if(angle > 60) {
  44. if(handMenu && handMenu.IsModuleStarted) {
  45. handMenu.ModuleStop();
  46. }
  47. }
  48. }
  49. }
  50. }
  51. }