OvrHandItemMgr.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. if (Product.isPublic)
  48. {
  49. f_nType = 0;
  50. }
  51. for (int i = 0; i < this.m_goItem.Length; i++)
  52. {
  53. GameObject gameObject = this.m_goItem[i];
  54. if (i == f_nType)
  55. {
  56. gameObject.SetActive(true);
  57. }
  58. else
  59. {
  60. gameObject.SetActive(false);
  61. }
  62. }
  63. }
  64. public void NextModel()
  65. {
  66. this.m_nModel++;
  67. if (this.m_goItem.Length <= this.m_nModel)
  68. {
  69. this.m_nModel = 0;
  70. }
  71. this.ChangeModel(this.m_nModel);
  72. }
  73. private void Update()
  74. {
  75. if (this.m_buttons != null)
  76. {
  77. if (this.m_buttons.GetPressDown(AVRControllerButtons.BTN.VIRTUAL_MENU))
  78. {
  79. this.m_fMenuPressBeforeTime = Time.realtimeSinceStartup;
  80. }
  81. else if (this.m_buttons.GetPress(AVRControllerButtons.BTN.VIRTUAL_MENU) && Time.realtimeSinceStartup - this.m_fMenuPressBeforeTime > 1f)
  82. {
  83. this.NextModel();
  84. this.m_fMenuPressBeforeTime = Time.realtimeSinceStartup;
  85. }
  86. }
  87. }
  88. public GameObject[] m_goItem = new GameObject[1];
  89. public AVRControllerBehavior m_ctrl;
  90. private Vector3 m_vBackPos;
  91. private AVRControllerButtons m_buttons;
  92. private int m_nModel;
  93. private float m_fMenuPressBeforeTime;
  94. }