123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- using System;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.UI;
- public class VRConfigMenu : MonoBehaviour
- {
- private void Refresh()
- {
- if (GameMain.Instance == null)
- {
- return;
- }
- this.m_2DMouseRotSpeed.SetActive(false);
- this.m_2DMouseRotInverse.SetActive(false);
- this.m_2DPlaneMovement.SetActive(false);
- this.m_2DShowMan.SetActive(false);
- this.m_2DFieldOfView.SetActive(false);
- this.m_NonTouchPlaneMovement.SetActive(false);
- this.m_NonTouchMouseRotEnable.SetActive(false);
- this.m_NonTouchMouseRotSpeed.SetActive(false);
- this.m_ViveFloorHeight.SetActive(false);
- this.m_ViveUseSnapRotate.SetActive(false);
- this.m_ViveUseSnapRotateRate.SetActive(false);
- this.m_TouchUseSnapRotate.SetActive(false);
- this.m_TouchUseSnapRotateRate.SetActive(false);
- this.m_CommonEyeHeight.SetActive(true);
- this.m_CommonSittingHeight.SetActive(true);
- this.m_CommonCameraRotSpeed.SetActive(true);
- this.m_CommonCameraMoveSpeed.SetActive(true);
- GameMain.VRDeviceType vrdeviceTypeID = GameMain.Instance.VRDeviceTypeID;
- if (vrdeviceTypeID == GameMain.VRDeviceType.NON)
- {
- this.m_2DMouseRotSpeed.SetActive(true);
- this.m_2DMouseRotInverse.SetActive(true);
- this.m_2DPlaneMovement.SetActive(true);
- this.m_2DShowMan.SetActive(true);
- this.m_2DFieldOfView.SetActive(true);
- }
- else if (vrdeviceTypeID == GameMain.VRDeviceType.RIFT)
- {
- this.m_NonTouchPlaneMovement.SetActive(true);
- this.m_NonTouchMouseRotEnable.SetActive(true);
- this.m_NonTouchMouseRotSpeed.SetActive(true);
- }
- else if (vrdeviceTypeID == GameMain.VRDeviceType.FOVE)
- {
- this.m_NonTouchPlaneMovement.SetActive(true);
- this.m_NonTouchMouseRotEnable.SetActive(true);
- this.m_NonTouchMouseRotSpeed.SetActive(true);
- }
- else if (vrdeviceTypeID == GameMain.VRDeviceType.VIVE)
- {
- this.m_ViveFloorHeight.SetActive(true);
- this.m_ViveUseSnapRotate.SetActive(true);
- this.m_ViveUseSnapRotateRate.SetActive(true);
- }
- else
- {
- this.m_TouchUseSnapRotate.SetActive(true);
- this.m_TouchUseSnapRotateRate.SetActive(true);
- }
- this.SetValue_Slider(this.m_CommonEyeHeight, 1.5f, 1.8f, GameMain.Instance.CMSystem.VRCameraHeightStand);
- this.SetValue_Slider(this.m_CommonSittingHeight, 0.7f, 1f, GameMain.Instance.CMSystem.VRCameraHeightSit);
- this.SetValue_Slider(this.m_CommonCameraRotSpeed, 0f, 1f, GameMain.Instance.CMSystem.VRCameraRotSpeedKey);
- this.SetValue_Slider(this.m_CommonCameraMoveSpeed, 0f, 1f, GameMain.Instance.CMSystem.VRCameraMoveSpeedKey);
- this.SetValue_Slider(this.m_NonTouchMouseRotSpeed, 0f, 1f, GameMain.Instance.CMSystem.VRCameraRotSpeedMouse);
- this.SetValue_Slider(this.m_2DMouseRotSpeed, 0f, 1f, GameMain.Instance.CMSystem.VRCameraRotSpeedMouse);
- this.SetValue_Slider(this.m_2DFieldOfView, 30f, 60f, GameMain.Instance.CMSystem.VRCameraFov);
- this.SetValue_Slider(this.m_ViveUseSnapRotateRate, 10f, 80f, (float)GameMain.Instance.CMSystem.OvrUseSnapRotateRate);
- this.SetValue_Slider(this.m_TouchUseSnapRotateRate, 10f, 80f, (float)GameMain.Instance.CMSystem.OvrUseSnapRotateRate);
- bool flag = GameMain.Instance.CMSystem.VRCameraPlaneMove;
- this.SetValue_ToggleButton(this.m_2DPlaneMovement, new bool[]
- {
- flag,
- !flag
- });
- flag = GameMain.Instance.CMSystem.VRCamRotDownUp;
- this.SetValue_ToggleButton(this.m_2DMouseRotInverse, new bool[]
- {
- flag,
- !flag
- });
- flag = GameMain.Instance.CMSystem.VRManShow;
- this.SetValue_ToggleButton(this.m_2DShowMan, new bool[]
- {
- flag,
- !flag
- });
- flag = GameMain.Instance.CMSystem.VRCameraPlaneMove;
- this.SetValue_ToggleButton(this.m_NonTouchPlaneMovement, new bool[]
- {
- flag,
- !flag
- });
- flag = GameMain.Instance.CMSystem.OvrMouseRot;
- this.SetValue_ToggleButton(this.m_NonTouchMouseRotEnable, new bool[]
- {
- flag,
- !flag
- });
- flag = (GameMain.Instance.CMSystem.OvrCameraHeightType == CMSystem.OVR_CAM_HEIGHT_TYPE.REAL);
- this.SetValue_ToggleButton(this.m_ViveFloorHeight, new bool[]
- {
- flag,
- !flag
- });
- flag = GameMain.Instance.CMSystem.OvrUseSnapRotate;
- this.SetValue_ToggleButton(this.m_ViveUseSnapRotate, new bool[]
- {
- flag,
- !flag
- });
- this.SetValue_ToggleButton(this.m_TouchUseSnapRotate, new bool[]
- {
- flag,
- !flag
- });
- VRConfigMenu.SetEvent_Slider(this.m_CommonEyeHeight, delegate(float value)
- {
- GameMain.Instance.CMSystem.VRCameraHeightStand = value;
- });
- VRConfigMenu.SetEvent_Slider(this.m_CommonSittingHeight, delegate(float value)
- {
- GameMain.Instance.CMSystem.VRCameraHeightSit = value;
- });
- VRConfigMenu.SetEvent_Slider(this.m_CommonCameraRotSpeed, delegate(float value)
- {
- GameMain.Instance.CMSystem.VRCameraRotSpeedKey = value;
- });
- VRConfigMenu.SetEvent_Slider(this.m_CommonCameraMoveSpeed, delegate(float value)
- {
- GameMain.Instance.CMSystem.VRCameraMoveSpeedKey = value;
- });
- VRConfigMenu.SetEvent_Slider(this.m_ViveUseSnapRotateRate, delegate(float value)
- {
- GameMain.Instance.CMSystem.OvrUseSnapRotateRate = (int)value;
- });
- VRConfigMenu.SetEvent_Slider(this.m_TouchUseSnapRotateRate, delegate(float value)
- {
- GameMain.Instance.CMSystem.OvrUseSnapRotateRate = (int)value;
- });
- VRConfigMenu.SetEvent_Slider(this.m_NonTouchMouseRotSpeed, delegate(float value)
- {
- GameMain.Instance.CMSystem.VRCameraRotSpeedMouse = value;
- });
- VRConfigMenu.SetEvent_Slider(this.m_2DMouseRotSpeed, delegate(float value)
- {
- GameMain.Instance.CMSystem.VRCameraRotSpeedMouse = value;
- });
- VRConfigMenu.SetEvent_Slider(this.m_2DFieldOfView, delegate(float value)
- {
- GameMain.Instance.CMSystem.VRCameraFov = value;
- });
- GameObject 2DMouseRotInverse = this.m_2DMouseRotInverse;
- UnityAction[] array = new UnityAction[2];
- array[0] = delegate()
- {
- GameMain.Instance.CMSystem.VRCamRotDownUp = true;
- };
- array[1] = delegate()
- {
- GameMain.Instance.CMSystem.VRCamRotDownUp = false;
- };
- VRConfigMenu.SetEvent_ToggleButton(2DMouseRotInverse, array);
- GameObject 2DPlaneMovement = this.m_2DPlaneMovement;
- UnityAction[] array2 = new UnityAction[2];
- array2[0] = delegate()
- {
- GameMain.Instance.CMSystem.VRCameraPlaneMove = true;
- };
- array2[1] = delegate()
- {
- GameMain.Instance.CMSystem.VRCameraPlaneMove = false;
- };
- VRConfigMenu.SetEvent_ToggleButton(2DPlaneMovement, array2);
- GameObject 2DShowMan = this.m_2DShowMan;
- UnityAction[] array3 = new UnityAction[2];
- array3[0] = delegate()
- {
- GameMain.Instance.CMSystem.VRManShow = true;
- };
- array3[1] = delegate()
- {
- GameMain.Instance.CMSystem.VRManShow = false;
- };
- VRConfigMenu.SetEvent_ToggleButton(2DShowMan, array3);
- GameObject viveUseSnapRotate = this.m_ViveUseSnapRotate;
- UnityAction[] array4 = new UnityAction[2];
- array4[0] = delegate()
- {
- GameMain.Instance.CMSystem.OvrUseSnapRotate = true;
- };
- array4[1] = delegate()
- {
- GameMain.Instance.CMSystem.OvrUseSnapRotate = false;
- };
- VRConfigMenu.SetEvent_ToggleButton(viveUseSnapRotate, array4);
- GameObject touchUseSnapRotate = this.m_TouchUseSnapRotate;
- UnityAction[] array5 = new UnityAction[2];
- array5[0] = delegate()
- {
- GameMain.Instance.CMSystem.OvrUseSnapRotate = true;
- };
- array5[1] = delegate()
- {
- GameMain.Instance.CMSystem.OvrUseSnapRotate = false;
- };
- VRConfigMenu.SetEvent_ToggleButton(touchUseSnapRotate, array5);
- GameObject nonTouchPlaneMovement = this.m_NonTouchPlaneMovement;
- UnityAction[] array6 = new UnityAction[2];
- array6[0] = delegate()
- {
- GameMain.Instance.CMSystem.VRCameraPlaneMove = true;
- };
- array6[1] = delegate()
- {
- GameMain.Instance.CMSystem.VRCameraPlaneMove = false;
- };
- VRConfigMenu.SetEvent_ToggleButton(nonTouchPlaneMovement, array6);
- GameObject nonTouchMouseRotEnable = this.m_NonTouchMouseRotEnable;
- UnityAction[] array7 = new UnityAction[2];
- array7[0] = delegate()
- {
- GameMain.Instance.CMSystem.OvrMouseRot = true;
- };
- array7[1] = delegate()
- {
- GameMain.Instance.CMSystem.OvrMouseRot = false;
- };
- VRConfigMenu.SetEvent_ToggleButton(nonTouchMouseRotEnable, array7);
- GameObject viveFloorHeight = this.m_ViveFloorHeight;
- UnityAction[] array8 = new UnityAction[2];
- array8[0] = delegate()
- {
- GameMain.Instance.CMSystem.OvrCameraHeightType = CMSystem.OVR_CAM_HEIGHT_TYPE.REAL;
- };
- array8[1] = delegate()
- {
- GameMain.Instance.CMSystem.OvrCameraHeightType = CMSystem.OVR_CAM_HEIGHT_TYPE.VR;
- };
- VRConfigMenu.SetEvent_ToggleButton(viveFloorHeight, array8);
- }
- private static void SetEvent_Slider(GameObject SliderObject, UnityAction<float> callback)
- {
- Slider componentInChildren = SliderObject.GetComponentInChildren<Slider>();
- componentInChildren.onValueChanged.RemoveAllListeners();
- componentInChildren.onValueChanged.AddListener(callback);
- }
- private static void SetEvent_ToggleButton(GameObject ButtonParentObject, params UnityAction[] callbacks)
- {
- Button[] buttons = ButtonParentObject.GetComponentsInChildren<Button>();
- for (int i = 0; i < buttons.Length; i++)
- {
- Button button = buttons[i];
- UnityAction callback = null;
- if (callbacks.Length > i)
- {
- callback = callbacks[i];
- }
- else
- {
- Debug.LogWarning("[VRConfig]フラグの数がイベントの数より少ない");
- }
- button.onClick.RemoveAllListeners();
- button.onClick.AddListener(delegate()
- {
- ColorBlock colors;
- for (int j = 0; j < buttons.Length; j++)
- {
- colors = buttons[j].colors;
- colors.normalColor = Color.white * 0.66f;
- buttons[j].colors = colors;
- }
- colors = button.colors;
- colors.normalColor = Color.white;
- button.colors = colors;
- callback();
- });
- }
- }
- private void SetValue_Slider(GameObject SliderObject, float min, float max, float value)
- {
- Slider componentInChildren = SliderObject.GetComponentInChildren<Slider>();
- componentInChildren.minValue = min;
- componentInChildren.maxValue = max;
- componentInChildren.value = value;
- }
- private void SetValue_ToggleButton(GameObject ButtonParentObject, params bool[] selecteds)
- {
- Button[] componentsInChildren = ButtonParentObject.GetComponentsInChildren<Button>();
- for (int i = 0; i < componentsInChildren.Length; i++)
- {
- Button button = componentsInChildren[i];
- bool flag = false;
- if (selecteds.Length > i)
- {
- flag = selecteds[i];
- }
- else
- {
- Debug.LogWarning("[VRConfig]フラグの数がボタンの数より少ない");
- }
- ColorBlock colors = componentsInChildren[i].colors;
- colors.normalColor = ((!flag) ? (Color.white * 0.66f) : Color.white);
- componentsInChildren[i].colors = colors;
- }
- }
- private void OnEnable()
- {
- this.Refresh();
- }
- [SerializeField]
- private GameObject m_CommonEyeHeight;
- [SerializeField]
- private GameObject m_CommonSittingHeight;
- [SerializeField]
- private GameObject m_CommonCameraRotSpeed;
- [SerializeField]
- private GameObject m_CommonCameraMoveSpeed;
- [SerializeField]
- private GameObject m_ViveFloorHeight;
- [SerializeField]
- private GameObject m_ViveUseSnapRotate;
- [SerializeField]
- private GameObject m_ViveUseSnapRotateRate;
- [SerializeField]
- private GameObject m_TouchUseSnapRotate;
- [SerializeField]
- private GameObject m_TouchUseSnapRotateRate;
- [SerializeField]
- private GameObject m_NonTouchPlaneMovement;
- [SerializeField]
- private GameObject m_NonTouchMouseRotEnable;
- [SerializeField]
- private GameObject m_NonTouchMouseRotSpeed;
- [SerializeField]
- private GameObject m_2DMouseRotSpeed;
- [SerializeField]
- private GameObject m_2DMouseRotInverse;
- [SerializeField]
- private GameObject m_2DPlaneMovement;
- [SerializeField]
- private GameObject m_2DShowMan;
- [SerializeField]
- private GameObject m_2DFieldOfView;
- }
|