Module_DockPanel.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using SC.XR.Unity;
  2. using SC.XR.Unity.Module_InputSystem;
  3. using SC.XR.Unity.Module_InputSystem.InputDeviceHand;
  4. using UnityEngine;
  5. public class Module_DockPanel : MonoBehaviour
  6. {
  7. bool _isProfileOn=false;
  8. bool _isBoundingBoxOn=false;
  9. bool _isHandJointOn=false;
  10. bool _isPinOn=true;
  11. bool _isBoundingBoxOntemp = false;
  12. HandModelType _tempModelType;
  13. int _HandJointIndex = 0;
  14. public Renderer[] _Backplates;
  15. Material _HandIcon;
  16. Texture2D _HandMeshTex;
  17. Texture2D _HandJointTex;
  18. Follower _follower;
  19. GameObject _performanceSamplerObj;
  20. // Start is called before the first frame update
  21. void Start()
  22. {
  23. InitState();
  24. }
  25. private void Update()
  26. {
  27. DeterBoundingbox();
  28. }
  29. void InitState()
  30. {
  31. _follower = GetComponent<Follower>();
  32. _isPinOn = _follower.StopFollower;
  33. _Backplates[3].enabled = !_isPinOn;
  34. _isBoundingBoxOn = API_Module_AddBorder.IsEnableFunc();
  35. _Backplates[1].enabled = _isBoundingBoxOn;
  36. _HandIcon = Resources.Load("Materials/HandJoint") as Material;
  37. _HandMeshTex = Resources.Load("Textures/IconHandMesh") as Texture2D;
  38. _HandJointTex = Resources.Load("Textures/IconHandJoint") as Texture2D;
  39. if (API_Module_SDKConfiguration.HasKey("Module_InputSystem", "HandModelType"))
  40. {
  41. System.Enum.TryParse<HandModelType>(API_Module_SDKConfiguration.GetString("Module_InputSystem", "HandModelType", "EffectHand"), false, out _tempModelType);
  42. }
  43. if (API_Module_SDKConfiguration.HasKey("Module_InputSystem", "ActiveGGT26Dof"))
  44. {
  45. _isHandJointOn = API_Module_SDKConfiguration.GetBool("Module_InputSystem", "ActiveGGT26Dof", 0);
  46. }
  47. if (_isHandJointOn)
  48. {
  49. _HandJointIndex = 1;
  50. _Backplates[2].enabled = _isHandJointOn;
  51. }
  52. if (_tempModelType==HandModelType.CubeHand)
  53. {
  54. _HandIcon.SetTexture("_MainTex", _HandJointTex);
  55. }
  56. else
  57. {
  58. _HandIcon.SetTexture("_MainTex", _HandMeshTex);
  59. }
  60. }
  61. public void ToggleHandJoint()
  62. {
  63. _HandJointIndex++;
  64. if (_HandJointIndex==1|| _HandJointIndex == 3)
  65. {
  66. _isHandJointOn = !_isHandJointOn;
  67. if (_isHandJointOn)
  68. {
  69. API_GSXR_Module_InputSystem.GSXR_Enable_InputDevice(InputDeviceType.GGT26Dof);
  70. }
  71. else
  72. {
  73. _HandJointIndex = 0;
  74. API_GSXR_Module_InputSystem.GSXR_Disable_InputDevice(InputDeviceType.GGT26Dof);
  75. }
  76. _Backplates[2].enabled = _isHandJointOn;
  77. }
  78. else if (_HandJointIndex==2)
  79. {
  80. if (_tempModelType == HandModelType.CubeHand)
  81. {
  82. _HandIcon.SetTexture("_MainTex", _HandMeshTex);
  83. _tempModelType = HandModelType.EffectHand;
  84. if (API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDeviceGGT26DofPartUI.modelGGT26Dof.gameObject.activeSelf)
  85. {
  86. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDeviceGGT26DofPartUI.modelGGT26Dof.HandModelChange(HandModelType.EffectHand);
  87. }
  88. if (API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDeviceGGT26DofPartUI.modelGGT26Dof.gameObject.activeSelf)
  89. {
  90. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDeviceGGT26DofPartUI.modelGGT26Dof.HandModelChange(HandModelType.EffectHand);
  91. }
  92. }
  93. else
  94. {
  95. _HandIcon.SetTexture("_MainTex", _HandJointTex);
  96. _tempModelType = HandModelType.CubeHand;
  97. if (API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDeviceGGT26DofPartUI.modelGGT26Dof.gameObject.activeSelf)
  98. {
  99. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDeviceGGT26DofPartUI.modelGGT26Dof.HandModelChange(HandModelType.CubeHand);
  100. }
  101. if (API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDeviceGGT26DofPartUI.modelGGT26Dof.gameObject.activeSelf)
  102. {
  103. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDeviceGGT26DofPartUI.modelGGT26Dof.HandModelChange(HandModelType.CubeHand);
  104. }
  105. }
  106. }
  107. }
  108. void DeterBoundingbox()
  109. {
  110. _isBoundingBoxOntemp = API_Module_AddBorder.IsEnableFunc();
  111. if (_isBoundingBoxOn!= _isBoundingBoxOntemp)
  112. {
  113. _isBoundingBoxOn = _isBoundingBoxOntemp;
  114. _Backplates[1].enabled = _isBoundingBoxOn;
  115. }
  116. }
  117. public void ToggleBoundingBox()
  118. {
  119. _isBoundingBoxOn = !_isBoundingBoxOn;
  120. _Backplates[1].enabled = _isBoundingBoxOn;
  121. if (_isBoundingBoxOn)
  122. {
  123. API_Module_AddBorder.OpenFunc();
  124. }
  125. else
  126. {
  127. API_Module_AddBorder.CloseFunc();
  128. }
  129. }
  130. public void TogglePin()
  131. {
  132. _isPinOn = !_isPinOn;
  133. _Backplates[3].enabled = !_isPinOn;
  134. _follower.StopFollower = _isPinOn;
  135. }
  136. public void ToggleProfile()
  137. {
  138. _isProfileOn = !_isProfileOn;
  139. ProfileController();
  140. }
  141. void ProfileController()
  142. {
  143. if (_isProfileOn)
  144. {
  145. if (_performanceSamplerObj == null)
  146. {
  147. _performanceSamplerObj = Instantiate(Resources.Load<GameObject>("UIPrefabs/PerformanceSampler"));
  148. }
  149. else
  150. {
  151. _performanceSamplerObj.SetActive(true);
  152. }
  153. _Backplates[0].enabled = true;
  154. }
  155. else
  156. {
  157. _performanceSamplerObj.SetActive(false);
  158. _Backplates[0].enabled=false;
  159. }
  160. }
  161. }