K102ControllerInfo.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using TMPro;
  4. using UnityEngine;
  5. using static API_GSXR_Slam;
  6. public class K102ControllerInfo : ControllerInfoBase
  7. {
  8. [SerializeField]
  9. protected TextMeshProUGUI Type;
  10. [SerializeField]
  11. protected TextMeshProUGUI Acc;
  12. [SerializeField]
  13. protected TextMeshProUGUI Gyro;
  14. float[] acc = new float[3];
  15. float[] gyro = new float[3];
  16. protected new void Start()
  17. {
  18. base.Start();
  19. }
  20. protected new void Update()
  21. {
  22. base.Update();
  23. ShowAcc();
  24. }
  25. private void ShowAcc()
  26. {
  27. if (is_Left)
  28. {
  29. API_GSXR_Slam.plugin.GSXR_Get_ControllerAccelerometer(acc, 0);
  30. API_GSXR_Slam.plugin.GSXR_Get_ControllerGyroscope(gyro, 0);
  31. }
  32. else
  33. {
  34. API_GSXR_Slam.plugin.GSXR_Get_ControllerAccelerometer(acc, 1);
  35. API_GSXR_Slam.plugin.GSXR_Get_ControllerGyroscope(gyro, 1);
  36. }
  37. Vector3 speed_1 = new Vector3(acc[0], acc[1], acc[2]);
  38. Vector3 speed_2 = new Vector3(gyro[0], gyro[1], gyro[2]);
  39. Acc.text = speed_1.ToString("f3");
  40. if (speed_1 != Vector3.zero)
  41. {
  42. ChangeColor_Green(Acc);
  43. }
  44. Gyro.text = speed_2.ToString("f3");
  45. if (speed_2 != Vector3.zero)
  46. {
  47. ChangeColor_Green(Gyro);
  48. }
  49. }
  50. }