OvrHandItemMgr.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using UnityEngine;
  3. public class OvrHandItemMgr : MonoBehaviour
  4. {
  5. public int ModelNum
  6. {
  7. get
  8. {
  9. return this.m_goItem.Length;
  10. }
  11. }
  12. public void SetButtons(AVRControllerButtons f_buttons)
  13. {
  14. this.m_buttons = f_buttons;
  15. }
  16. private void Awake()
  17. {
  18. this.m_vBackPos = base.transform.localPosition;
  19. }
  20. private void Start()
  21. {
  22. this.ChangeModel(0);
  23. }
  24. private void OnEnable()
  25. {
  26. if (OvrIK.IsModeVRIK)
  27. {
  28. if (this.m_ctrl != null)
  29. {
  30. if (this.m_ctrl.m_bHandL)
  31. {
  32. base.transform.localPosition = new Vector3(0.009f, -0.068f, -0.109f);
  33. }
  34. else
  35. {
  36. base.transform.localPosition = new Vector3(-0.021f, -0.044f, -0.1f);
  37. }
  38. }
  39. }
  40. else
  41. {
  42. base.transform.localPosition = this.m_vBackPos;
  43. }
  44. }
  45. public void ChangeModel(int f_nType)
  46. {
  47. for (int i = 0; i < this.m_goItem.Length; i++)
  48. {
  49. GameObject gameObject = this.m_goItem[i];
  50. if (i == f_nType)
  51. {
  52. gameObject.SetActive(true);
  53. }
  54. else
  55. {
  56. gameObject.SetActive(false);
  57. }
  58. }
  59. }
  60. public void NextModel()
  61. {
  62. this.m_nModel++;
  63. if (this.m_goItem.Length <= this.m_nModel)
  64. {
  65. this.m_nModel = 0;
  66. }
  67. this.ChangeModel(this.m_nModel);
  68. }
  69. private void Update()
  70. {
  71. if (this.m_buttons != null)
  72. {
  73. if (this.m_buttons.GetPressDown(AVRControllerButtons.BTN.VIRTUAL_MENU))
  74. {
  75. this.m_fMenuPressBeforeTime = Time.realtimeSinceStartup;
  76. }
  77. else if (this.m_buttons.GetPress(AVRControllerButtons.BTN.VIRTUAL_MENU) && Time.realtimeSinceStartup - this.m_fMenuPressBeforeTime > 1f)
  78. {
  79. this.NextModel();
  80. this.m_fMenuPressBeforeTime = Time.realtimeSinceStartup;
  81. }
  82. }
  83. }
  84. public GameObject[] m_goItem = new GameObject[1];
  85. public AVRControllerBehavior m_ctrl;
  86. private Vector3 m_vBackPos;
  87. private AVRControllerButtons m_buttons;
  88. private int m_nModel;
  89. private float m_fMenuPressBeforeTime;
  90. }