123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- using SC.XR.Unity;
- using SC.XR.Unity.Module_InputSystem;
- using SC.XR.Unity.Module_InputSystem.InputDeviceHand;
- using UnityEngine;
- public class Module_DockPanel : MonoBehaviour
- {
- bool _isProfileOn=false;
- bool _isBoundingBoxOn=false;
- bool _isHandJointOn=false;
- bool _isPinOn=true;
- bool _isBoundingBoxOntemp = false;
- HandModelType _tempModelType;
- int _HandJointIndex = 0;
- public Renderer[] _Backplates;
- Material _HandIcon;
- Texture2D _HandMeshTex;
- Texture2D _HandJointTex;
- Follower _follower;
- GameObject _performanceSamplerObj;
- // Start is called before the first frame update
- void Start()
- {
- InitState();
- }
- private void Update()
- {
- DeterBoundingbox();
- }
- void InitState()
- {
- _follower = GetComponent<Follower>();
- _isPinOn = _follower.StopFollower;
- _Backplates[3].enabled = !_isPinOn;
- _isBoundingBoxOn = API_Module_AddBorder.IsEnableFunc();
- _Backplates[1].enabled = _isBoundingBoxOn;
- _HandIcon = Resources.Load("Materials/HandJoint") as Material;
- _HandMeshTex = Resources.Load("Textures/IconHandMesh") as Texture2D;
- _HandJointTex = Resources.Load("Textures/IconHandJoint") as Texture2D;
- if (API_Module_SDKConfiguration.HasKey("Module_InputSystem", "HandModelType"))
- {
- System.Enum.TryParse<HandModelType>(API_Module_SDKConfiguration.GetString("Module_InputSystem", "HandModelType", "EffectHand"), false, out _tempModelType);
- }
- if (API_Module_SDKConfiguration.HasKey("Module_InputSystem", "ActiveGGT26Dof"))
- {
- _isHandJointOn = API_Module_SDKConfiguration.GetBool("Module_InputSystem", "ActiveGGT26Dof", 0);
- }
- if (_isHandJointOn)
- {
- _HandJointIndex = 1;
- _Backplates[2].enabled = _isHandJointOn;
- }
- if (_tempModelType==HandModelType.CubeHand)
- {
- _HandIcon.SetTexture("_MainTex", _HandJointTex);
- }
- else
- {
- _HandIcon.SetTexture("_MainTex", _HandMeshTex);
- }
- }
- public void ToggleHandJoint()
- {
- _HandJointIndex++;
- if (_HandJointIndex==1|| _HandJointIndex == 3)
- {
- _isHandJointOn = !_isHandJointOn;
- if (_isHandJointOn)
- {
- API_GSXR_Module_InputSystem.GSXR_Enable_InputDevice(InputDeviceType.GGT26Dof);
- }
- else
- {
- _HandJointIndex = 0;
- API_GSXR_Module_InputSystem.GSXR_Disable_InputDevice(InputDeviceType.GGT26Dof);
- }
- _Backplates[2].enabled = _isHandJointOn;
- }
- else if (_HandJointIndex==2)
- {
- if (_tempModelType == HandModelType.CubeHand)
- {
- _HandIcon.SetTexture("_MainTex", _HandMeshTex);
- _tempModelType = HandModelType.EffectHand;
- if (API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDeviceGGT26DofPartUI.modelGGT26Dof.gameObject.activeSelf)
- {
- API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDeviceGGT26DofPartUI.modelGGT26Dof.HandModelChange(HandModelType.EffectHand);
- }
- if (API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDeviceGGT26DofPartUI.modelGGT26Dof.gameObject.activeSelf)
- {
- API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDeviceGGT26DofPartUI.modelGGT26Dof.HandModelChange(HandModelType.EffectHand);
- }
- }
- else
- {
- _HandIcon.SetTexture("_MainTex", _HandJointTex);
- _tempModelType = HandModelType.CubeHand;
- if (API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDeviceGGT26DofPartUI.modelGGT26Dof.gameObject.activeSelf)
- {
- API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDeviceGGT26DofPartUI.modelGGT26Dof.HandModelChange(HandModelType.CubeHand);
- }
- if (API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDeviceGGT26DofPartUI.modelGGT26Dof.gameObject.activeSelf)
- {
- API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDeviceGGT26DofPartUI.modelGGT26Dof.HandModelChange(HandModelType.CubeHand);
- }
-
- }
- }
- }
- void DeterBoundingbox()
- {
- _isBoundingBoxOntemp = API_Module_AddBorder.IsEnableFunc();
- if (_isBoundingBoxOn!= _isBoundingBoxOntemp)
- {
- _isBoundingBoxOn = _isBoundingBoxOntemp;
- _Backplates[1].enabled = _isBoundingBoxOn;
- }
- }
- public void ToggleBoundingBox()
- {
- _isBoundingBoxOn = !_isBoundingBoxOn;
- _Backplates[1].enabled = _isBoundingBoxOn;
- if (_isBoundingBoxOn)
- {
- API_Module_AddBorder.OpenFunc();
- }
- else
- {
- API_Module_AddBorder.CloseFunc();
- }
- }
- public void TogglePin()
- {
- _isPinOn = !_isPinOn;
- _Backplates[3].enabled = !_isPinOn;
- _follower.StopFollower = _isPinOn;
- }
- public void ToggleProfile()
- {
- _isProfileOn = !_isProfileOn;
- ProfileController();
- }
- void ProfileController()
- {
- if (_isProfileOn)
- {
- if (_performanceSamplerObj == null)
- {
- _performanceSamplerObj = Instantiate(Resources.Load<GameObject>("UIPrefabs/PerformanceSampler"));
- }
- else
- {
- _performanceSamplerObj.SetActive(true);
- }
- _Backplates[0].enabled = true;
- }
- else
- {
- _performanceSamplerObj.SetActive(false);
- _Backplates[0].enabled=false;
- }
- }
- }
|