ModelK07.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace SC.XR.Unity.Module_InputSystem.InputDeviceGC.KS {
  6. public class ModelK07 : ModelGCBase {
  7. public InputDeviceKSPartUI inputDeviceKSPartUI {
  8. get {
  9. return inputDevicePartUIBase as InputDeviceKSPartUI;
  10. }
  11. }
  12. public MeshRenderer backKey;
  13. public MeshRenderer functionKey;
  14. public MeshRenderer triggerKey;
  15. public TpInfo tpInfo;
  16. public MeshRenderer volumeDown;
  17. public MeshRenderer volumeUp;
  18. public MeshRenderer tpKey;
  19. [Serializable]
  20. public class TpInfo {
  21. public Transform tpPosition;
  22. }
  23. public Material pressMaterial;
  24. public Material releaseMaterial;
  25. public Vector3 modelPositionDeltaWithDevice = new Vector3(0, 0, 0.20f);
  26. void UpdateTransform() {
  27. transform.localPosition = modelPositionDeltaWithDevice;
  28. }
  29. public override void OnSCLateUpdate() {
  30. base.OnSCLateUpdate();
  31. UpdateTransform();
  32. }
  33. public override void SetTpPosition() {
  34. if (inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.touchPanelAction == TouchPanelAction.DOWN || inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.touchPanelAction == TouchPanelAction.MOVE) {
  35. //tpPosition.gameObject.activeSelf ? tpPosition.gameObject.SetActive(true) : null;
  36. if (!tpInfo.tpPosition.gameObject.activeSelf) {
  37. tpInfo.tpPosition.gameObject.SetActive(true);
  38. }
  39. tpInfo.tpPosition.localPosition = new Vector3(
  40. (inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.tpPosition.x - 125) * 0.00012f,
  41. tpInfo.tpPosition.localPosition.y,
  42. (inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.tpPosition.y - 125) * 0.00012f);
  43. //if (touchDircionCoroutine == null) {
  44. // ////Debug.Log("wangcq327 --- StartCoroutine device " +inputDeviceType);
  45. // //touchDircionCoroutine = StartCoroutine("TouchEvent", (inputDeviceType == InputDeviceType.HandShankMain) ? 0 : 1);
  46. //}
  47. } else {
  48. if (tpInfo.tpPosition.gameObject.activeSelf) {
  49. tpInfo.tpPosition.gameObject.SetActive(false);
  50. }
  51. //if (touchDircionCoroutine != null) {
  52. // StopCoroutine("TouchEvent");
  53. // touchDircionCoroutine = null;
  54. //}
  55. }
  56. }
  57. public override void SetHandleKeysColor() {
  58. if (releaseMaterial == null || pressMaterial == null) {
  59. return;
  60. }
  61. foreach (var item in inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.inputKeys.inputKeyDic) {
  62. if (item.Key == InputKeyCode.Trigger) {
  63. triggerKey.material = releaseMaterial;
  64. if (item.Value == InputKeyState.DOWN || item.Value == InputKeyState.LONG) {
  65. triggerKey.material = pressMaterial;
  66. }
  67. } else if (item.Key == InputKeyCode.Function) {
  68. functionKey.material = releaseMaterial;
  69. if (item.Value == InputKeyState.DOWN || item.Value == InputKeyState.LONG) {
  70. functionKey.material = pressMaterial;
  71. }
  72. } else if (item.Key == InputKeyCode.Back) {
  73. backKey.material = releaseMaterial;
  74. if (item.Value == InputKeyState.DOWN || item.Value == InputKeyState.LONG) {
  75. backKey.material = pressMaterial;
  76. }
  77. }else if (item.Key == InputKeyCode.Tp) {
  78. tpKey.material = releaseMaterial;
  79. if (item.Value == InputKeyState.DOWN || item.Value == InputKeyState.LONG) {
  80. tpKey.material = pressMaterial;
  81. }
  82. } else if (item.Key == InputKeyCode.VolumeDown) {
  83. volumeDown.material = releaseMaterial;
  84. if (item.Value == InputKeyState.DOWN || item.Value == InputKeyState.LONG) {
  85. volumeDown.material = pressMaterial;
  86. }
  87. } else if (item.Key == InputKeyCode.VolumeUp) {
  88. volumeUp.material = releaseMaterial;
  89. if (item.Value == InputKeyState.DOWN || item.Value == InputKeyState.LONG) {
  90. volumeUp.material = pressMaterial;
  91. }
  92. }
  93. }
  94. }
  95. }
  96. }