ModelBT3DofBase.cs 3.6 KB

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