using System; using System.Collections.Generic; using Kasizuki; using UnityEngine; public class ConfigVRCtrl : NGUIWindow { public static ConfigVRCtrl instance { get { Transform transform = null; GameObject gameObject = GameObject.Find("SystemUI Root"); if (gameObject) { transform = gameObject.transform; } else { NDebug.Assert("SystemUI Rootが見つかりません", false); } if (ConfigVRCtrl.m_Instance == null) { Transform transform2 = transform.Find("ConfigVR"); if (transform2 != null) { ConfigVRCtrl.m_Instance = transform2.GetComponent(); } } if (ConfigVRCtrl.m_Instance == null) { string path = "SystemUI/Config/Prefab/ConfigVR"; GameObject gameObject2 = Resources.Load(path); if (gameObject2 == null) { NDebug.Assert("[ConfigVRCtrl] VRコンフィグUIのプレハブが存在しません", false); } ConfigVRCtrl.m_Instance = UnityEngine.Object.Instantiate(gameObject2).GetComponent(); ConfigVRCtrl.m_Instance.transform.SetParent(transform, false); ConfigVRCtrl.m_Instance.transform.localPosition = new Vector3(0f, -11f, 0f); ConfigVRCtrl.m_Instance.transform.localRotation = Quaternion.identity; ConfigVRCtrl.m_Instance.transform.localScale = Vector3.one; } if (ConfigVRCtrl.m_Instance == null) { NDebug.Assert("[ConfigVRCtrl] VRコンフィグUIのインスタンス取得に失敗しました", false); } return ConfigVRCtrl.m_Instance; } } public static bool IsOpen() { return ConfigVRCtrl.instance != null && ConfigVRCtrl.instance.gameObject.activeSelf; } public static void Open(Action onClickOK = null) { if (ConfigVRCtrl.IsOpen()) { Debug.Log("[ConfigVRCtrl] VRConfigは既に開かれています。"); return; } ConfigVRCtrl component = ConfigVRCtrl.instance.GetComponent(); NGUIWindow component2 = ConfigVRCtrl.instance.GetComponent(); component.onClickOK = onClickOK; component.LoadConfigData(); component2.Open(0.25f, null); } public static void Close(bool isExecutionOK = true) { ConfigVRCtrl component = ConfigVRCtrl.instance.GetComponent(); NGUIWindow component2 = ConfigVRCtrl.instance.GetComponent(); component2.Close(0.25f, delegate { UnityEngine.Object.Destroy(ConfigVRCtrl.instance.gameObject); }); if (isExecutionOK && component.onClickOK != null) { component.onClickOK(); } } private Dictionary dicItem { get { return this.m_DicItem; } set { this.m_DicItem = value; } } private CMSystem cmSystem { get { return GameMain.Instance.CMSystem; } } private void Log(object message) { Debug.Log(message); } public Action onClickOK { get; set; } public Action onClickChangeConfig { get; set; } protected override void Awake() { base.Awake(); this.SetupAllUI(); this.LoadConfigData(); this.ItemSwitchingOfDevice(); } private void SetupAllUI() { base.cachedObjectDic.CacheChildObject(base.gameObject, "OK", "ButtonOK"); EventDelegate.Add(base.cachedObjectDic.GetCache("ButtonOK").onClick, delegate() { ConfigVRCtrl.Close(true); }); base.cachedObjectDic.CacheChildObject(base.gameObject, "Change Normal", "ButtonChange"); EventDelegate.Add(base.cachedObjectDic.GetCache("ButtonChange").onClick, delegate() { ConfigVRCtrl.Close(true); BaseMgr.Instance.OpenConfigPanel(); }); base.cachedObjectDic.CacheChildObject(base.gameObject, "BG", "Background"); base.cachedObjectDic.CacheChildObject(base.gameObject, "label notes", "注意書き"); base.cachedObjectDic.GetCache("注意書き").gameObject.SetActive(!GameMain.Instance.VRMode); UIGrid uigrid = base.cachedObjectDic.CacheChildObject(base.gameObject, "DataList/ScrollView/Grid", "Parent Grid"); this.dicItem = new Dictionary(); this.SetupCommonUI(uigrid.gameObject); this.SetupViveUI(uigrid.gameObject); this.SetupOculusTouchUI(uigrid.gameObject); this.SetupHMDOnlyUI(uigrid.gameObject); this.Setup2DModeUI(uigrid.gameObject); } private void SetupCommonUI(GameObject parentItem) { this.dicItem.Add(ConfigVRCtrl.TypeItem.CommonEyeHeight, this.SetupSlider(parentItem, "common eye height", ConfigVRCtrl.COMMON_EYE_HEIGHT_VALUE.x, ConfigVRCtrl.COMMON_EYE_HEIGHT_VALUE.y, delegate(float value) { this.cmSystem.VRCameraHeightStand = value; this.Log("身長 : " + this.cmSystem.VRCameraHeightStand); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.CommonSitHeight, this.SetupSlider(parentItem, "common sitting height", ConfigVRCtrl.COMMON_SITTING_HEIGHT_VALUE.x, ConfigVRCtrl.COMMON_SITTING_HEIGHT_VALUE.y, delegate(float value) { this.cmSystem.VRCameraHeightSit = value; this.Log("座高 : " + this.cmSystem.VRCameraHeightSit); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.CommonCameraMoveSpeed, this.SetupSlider(parentItem, "common camera move speed", ConfigVRCtrl.COMMON_CAMERA_MOVE_VALUE.x, ConfigVRCtrl.COMMON_CAMERA_MOVE_VALUE.y, delegate(float value) { this.cmSystem.VRCameraMoveSpeedKey = value; this.Log("カメラ移動速度(キーボード) : " + this.cmSystem.VRCameraMoveSpeedKey); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.CommonCameraRotSpeed, this.SetupSlider(parentItem, "common camera rot speed", ConfigVRCtrl.COMMON_CAMERA_ROT_VALUE.x, ConfigVRCtrl.COMMON_CAMERA_ROT_VALUE.y, delegate(float value) { this.cmSystem.VRCameraRotSpeedKey = value; this.Log("カメラ回転速度(キーボード) : " + this.cmSystem.VRCameraRotSpeedKey); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.CommonShowDesktopScreen, this.SetupButton(parentItem, "common show desktop screen", delegate(bool isLeft) { if (isLeft && !GameMain.Instance.BgMgr.isShowDesktopScreen) { GameMain.Instance.BgMgr.SetShowDesktopScreen(true); } else if (!isLeft && GameMain.Instance.BgMgr.isShowDesktopScreen) { GameMain.Instance.BgMgr.SetShowDesktopScreen(false); } this.Log("デスクトップスクリーンの表示 + " + GameMain.Instance.BgMgr.isShowDesktopScreen); })); } private void SetupViveUI(GameObject parentItem) { this.dicItem.Add(ConfigVRCtrl.TypeItem.ViveFloorHeightType, this.SetupButton(parentItem, "vive floor height", delegate(bool isLeft) { this.cmSystem.OvrCameraHeightType = ((!isLeft) ? CMSystem.OVR_CAM_HEIGHT_TYPE.VR : CMSystem.OVR_CAM_HEIGHT_TYPE.REAL); this.Log("Vive\u3000床の高さ検出法 : " + this.cmSystem.OvrCameraHeightType.ToString()); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.ViveMoveMode, this.SetupButton(parentItem, "vive move mode", delegate(bool isLeft) { this.cmSystem.SConfig.OvrMoveType = ((!isLeft) ? CMSystem.SerializeConfig.OVR_MOVE_TYPE.DIRECTION : CMSystem.SerializeConfig.OVR_MOVE_TYPE.WARP_DRAW_STEPROT); this.Log("Vive\u3000移動方法 : " + this.cmSystem.SConfig.OvrMoveType); if (isLeft) { this.SetItemShowFlag(ConfigVRCtrl.TypeItem.ViveSnapRotateEnable, true); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.ViveSnapRotateRate, true); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.ViveOldRotatePad, false); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.ViveOldMovePad, false); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.ViveOldMoveRotatePadAriaRate, false); } else { this.SetItemShowFlag(ConfigVRCtrl.TypeItem.ViveSnapRotateEnable, false); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.ViveSnapRotateRate, false); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.ViveOldRotatePad, true); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.ViveOldMovePad, true); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.ViveOldMoveRotatePadAriaRate, true); } })); this.dicItem.Add(ConfigVRCtrl.TypeItem.ViveSnapRotateEnable, this.SetupButton(parentItem, "vive use snap rotate", delegate(bool isLeft) { this.cmSystem.OvrUseSnapRotate = isLeft; this.Log("Vive\u3000パッド端で回転 : " + this.cmSystem.OvrUseSnapRotate); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.ViveSnapRotateRate, this.SetupSlider(parentItem, "vive use snap rotate rate", ConfigVRCtrl.VR_CAMERA_SNAP_ROT_VALUE.x, ConfigVRCtrl.VR_CAMERA_SNAP_ROT_VALUE.y, delegate(float value) { this.cmSystem.OvrUseSnapRotateRate = (int)value; this.Log("Vive\u3000パッド端の回転量 : " + this.cmSystem.OvrUseSnapRotateRate); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.ViveOldRotatePad, this.SetupButton(parentItem, "vive old rotate pad", delegate(bool isLeft) { this.cmSystem.SConfig.OvrViveSmoothRotatePadAreaUse = isLeft; this.Log("Vive\u3000(スムーズ移動)パッド左右端で回転 : " + this.cmSystem.SConfig.OvrViveSmoothRotatePadAreaUse); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.ViveOldMovePad, this.SetupButton(parentItem, "vive old move pad", delegate(bool isLeft) { this.cmSystem.SConfig.OvrViveSmoothupDownPadAreaUse = isLeft; this.Log("Vive\u3000(スムーズ移動)パッド上下端で上下 : " + this.cmSystem.SConfig.OvrViveSmoothupDownPadAreaUse); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.ViveOldMoveRotatePadAriaRate, this.SetupSlider(parentItem, "vive old rotate pad aria rate", 10f, 80f, delegate(float value) { this.cmSystem.SConfig.OvrViveSmoothRotatePadAriaRate = value; this.Log("Vive\u3000(スムーズ移動)端の領域 : " + this.cmSystem.SConfig.OvrViveSmoothRotatePadAriaRate); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.ViveDDTouchToClick, this.SetupButton(parentItem, "vive dd touch to click", delegate(bool isLeft) { this.cmSystem.SConfig.OvrDDTouchToClick = isLeft; this.Log("Vive\u3000デスクトップスクリーンに触れるとクリック : " + this.cmSystem.SConfig.OvrDDTouchToClick); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.ViveOvrTabletFrameHideWhenMsgWndVisible, this.SetupButton(parentItem, "vive OvrTabletFrameHideWhenMsgWndVisible", delegate(bool isLeft) { this.cmSystem.SConfig.OvrTabletFrameHideWhenMsgWndVisible = isLeft; this.Log("Vive\u3000メッセージ中タブレット枠を非表示 : " + this.cmSystem.SConfig.OvrTabletFrameHideWhenMsgWndVisible); })); } private void SetupOculusTouchUI(GameObject parentItem) { this.dicItem.Add(ConfigVRCtrl.TypeItem.TouchMoveMode, this.SetupButton(parentItem, "touch move mode", delegate(bool isLeft) { this.cmSystem.SConfig.OvrMoveType = ((!isLeft) ? CMSystem.SerializeConfig.OVR_MOVE_TYPE.DIRECTION : CMSystem.SerializeConfig.OVR_MOVE_TYPE.WARP_DRAW_STEPROT); this.Log("Touch\u3000移動方法 : " + this.cmSystem.SConfig.OvrMoveType); if (isLeft) { this.SetItemShowFlag(ConfigVRCtrl.TypeItem.TouchSnapRotateEnable, true); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.TouchSnapRotateRate, true); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.TouchOldMoveStick, false); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.TouchOldRotateStick, false); } else { this.SetItemShowFlag(ConfigVRCtrl.TypeItem.TouchSnapRotateEnable, false); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.TouchSnapRotateRate, false); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.TouchOldMoveStick, true); this.SetItemShowFlag(ConfigVRCtrl.TypeItem.TouchOldRotateStick, true); } })); this.dicItem.Add(ConfigVRCtrl.TypeItem.TouchSnapRotateEnable, this.SetupButton(parentItem, "touch use snap rotate", delegate(bool isLeft) { this.cmSystem.OvrUseSnapRotate = isLeft; this.Log("Touch\u3000スティック傾けで回転 : " + this.cmSystem.OvrUseSnapRotate); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.TouchSnapRotateRate, this.SetupSlider(parentItem, "touch use snap rotate rate", ConfigVRCtrl.VR_CAMERA_SNAP_ROT_VALUE.x, ConfigVRCtrl.VR_CAMERA_SNAP_ROT_VALUE.y, delegate(float value) { this.cmSystem.OvrUseSnapRotateRate = (int)value; this.Log("Touch\u3000スティック傾けの回転量 : " + this.cmSystem.OvrUseSnapRotateRate); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.TouchOldMoveStick, this.SetupButton(parentItem, "touch old move stick", delegate(bool isLeft) { this.cmSystem.SConfig.OvrRiftTriggerStickUpDown = isLeft; this.Log("Touch\u3000(スムーズ移動)グリップとスティックで回転 : " + this.cmSystem.SConfig.OvrRiftTriggerStickUpDown); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.TouchOldRotateStick, this.SetupButton(parentItem, "touch old rotate stick", delegate(bool isLeft) { this.cmSystem.SConfig.OvrRiftGripStickRotate = isLeft; this.Log("Touch\u3000(スムーズ移動)トリガーとスティックで上下 : " + this.cmSystem.SConfig.OvrRiftGripStickRotate); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.TouchDDTouchToClick, this.SetupButton(parentItem, "touch dd touch to click", delegate(bool isLeft) { this.cmSystem.SConfig.OvrDDTouchToClick = isLeft; this.Log("Touch\u3000デスクトップスクリーンに触れるとクリック : " + this.cmSystem.SConfig.OvrDDTouchToClick); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.TouchOvrTabletFrameHideWhenMsgWndVisible, this.SetupButton(parentItem, "touch OvrTabletFrameHideWhenMsgWndVisible", delegate(bool isLeft) { this.cmSystem.SConfig.OvrTabletFrameHideWhenMsgWndVisible = isLeft; this.Log("Touch\u3000メッセージ中タブレット枠を非表示 : " + this.cmSystem.SConfig.OvrTabletFrameHideWhenMsgWndVisible); })); } private void SetupHMDOnlyUI(GameObject parentItem) { this.dicItem.Add(ConfigVRCtrl.TypeItem.HMDOnlyCameraPlaneMovement, this.SetupButton(parentItem, "no touch plane movement", delegate(bool isLeft) { this.cmSystem.VRCameraPlaneMove = isLeft; this.Log("HMDのみ\u3000カメラの平行移動 : " + this.cmSystem.VRCameraPlaneMove); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.HMDOnlyMouseRotateEnable, this.SetupButton(parentItem, "no touch mouse rot enable", delegate(bool isLeft) { this.cmSystem.OvrMouseRot = isLeft; this.Log("HMDのみ\u3000マウスでカメラ回転 : " + this.cmSystem.OvrMouseRot); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.HMDOnlyMouseRotateSpeed, this.SetupSlider(parentItem, "no touch mouse rot speed", ConfigVRCtrl.VR_CAMERA_MOUSE_ROT_VALUE.x, ConfigVRCtrl.VR_CAMERA_MOUSE_ROT_VALUE.y, delegate(float value) { this.cmSystem.VRCameraRotSpeedMouse = value; this.Log("HMDのみ\u3000マウスのカメラ回転速度 : " + this.cmSystem.VRCameraRotSpeedMouse); })); } private void Setup2DModeUI(GameObject parentItem) { this.dicItem.Add(ConfigVRCtrl.TypeItem.DummyMouseRotateSpeed, this.SetupSlider(parentItem, "2d mouse rot speed", ConfigVRCtrl.VR_CAMERA_MOUSE_ROT_VALUE.x, ConfigVRCtrl.VR_CAMERA_MOUSE_ROT_VALUE.y, delegate(float value) { this.cmSystem.VRCameraRotSpeedMouse = value; this.Log("2Dモード\u3000マウスのカメラ回転速度 : " + this.cmSystem.VRCameraRotSpeedMouse); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.DummyMouseRotateInverse, this.SetupButton(parentItem, "2d mouse rot inverse", delegate(bool isLeft) { this.cmSystem.VRCamRotDownUp = isLeft; this.Log("2Dモード\u3000マウスのカメラ反転 : " + this.cmSystem.VRCamRotDownUp); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.DummyCameraPlaneMovement, this.SetupButton(parentItem, "2d plane movement", delegate(bool isLeft) { this.cmSystem.VRCameraPlaneMove = isLeft; this.Log("2Dモード\u3000カメラの平行移動 : " + this.cmSystem.VRCameraPlaneMove); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.DummyShowMan, this.SetupButton(parentItem, "2d show man", delegate(bool isLeft) { this.cmSystem.VRManShow = isLeft; this.Log("2Dモード\u3000男の表示 : " + this.cmSystem.VRManShow); })); this.dicItem.Add(ConfigVRCtrl.TypeItem.DummyCameraFov, this.SetupSlider(parentItem, "2d camera field of view", ConfigVRCtrl.VR2D_CAMERA_FOV_VALUE.x, ConfigVRCtrl.VR2D_CAMERA_FOV_VALUE.y, delegate(float value) { this.cmSystem.VRCameraFov = value; this.Log("2Dモード\u3000カメラの画角 : " + this.cmSystem.VRCameraFov); })); Collider[] componentsInChildren = this.dicItem[ConfigVRCtrl.TypeItem.DummyCameraFov].GetComponentsInChildren(); foreach (Collider collider in componentsInChildren) { UIEventTrigger uieventTrigger = collider.gameObject.AddComponent(); EventDelegate.Add(uieventTrigger.onPress, delegate() { UISprite cache = base.cachedObjectDic.GetCache("Background"); TweenAlpha.Begin(cache.gameObject, 0.25f, 0.25f); }); EventDelegate.Add(uieventTrigger.onRelease, delegate() { UISprite cache = base.cachedObjectDic.GetCache("Background"); TweenAlpha.Begin(cache.gameObject, 0.25f, 1f); }); } } private ConfigVRCtrl.ParentSlider SetupSlider(GameObject parent, string objName, float min, float max, Action onValueChanged) { ConfigVRCtrl.ParentSlider parentSlider = UTY.GetChildObject(parent, objName, false).AddComponent(); parentSlider.min = min; parentSlider.max = max; ConfigVRCtrl.ParentSlider parentSlider2 = parentSlider; parentSlider2.onValueChanged = (Action)Delegate.Combine(parentSlider2.onValueChanged, onValueChanged); return parentSlider; } private ConfigVRCtrl.ParentButton SetupButton(GameObject parent, string objName, Action onClickIsLeft) { ConfigVRCtrl.ParentButton parentButton = UTY.GetChildObject(parent, objName, false).AddComponent(); ConfigVRCtrl.ParentButton parentButton2 = parentButton; parentButton2.onClickIsLeft = (Action)Delegate.Combine(parentButton2.onClickIsLeft, onClickIsLeft); return parentButton; } private void ItemSwitchingOfDevice() { if (this.dicItem == null) { Debug.Log("[ConfigVRCtrl] まだ項目の初期化は行っていません"); return; } GameMain.VRDeviceType vrdeviceTypeID = GameMain.Instance.VRDeviceTypeID; Dictionary dictionary = new Dictionary(); Array values = Enum.GetValues(typeof(ConfigVRCtrl.TypeItem)); for (int i = 0; i < values.Length; i++) { dictionary.Add((ConfigVRCtrl.TypeItem)values.GetValue(i), false); } dictionary[ConfigVRCtrl.TypeItem.CommonCameraMoveSpeed] = true; dictionary[ConfigVRCtrl.TypeItem.CommonCameraRotSpeed] = true; dictionary[ConfigVRCtrl.TypeItem.CommonEyeHeight] = true; dictionary[ConfigVRCtrl.TypeItem.CommonSitHeight] = true; dictionary[ConfigVRCtrl.TypeItem.CommonShowDesktopScreen] = true; if (vrdeviceTypeID == GameMain.VRDeviceType.NON) { dictionary[ConfigVRCtrl.TypeItem.DummyCameraFov] = true; dictionary[ConfigVRCtrl.TypeItem.DummyCameraPlaneMovement] = true; dictionary[ConfigVRCtrl.TypeItem.DummyMouseRotateInverse] = true; dictionary[ConfigVRCtrl.TypeItem.DummyMouseRotateSpeed] = true; dictionary[ConfigVRCtrl.TypeItem.DummyShowMan] = true; } else if (vrdeviceTypeID == GameMain.VRDeviceType.RIFT) { dictionary[ConfigVRCtrl.TypeItem.HMDOnlyCameraPlaneMovement] = true; dictionary[ConfigVRCtrl.TypeItem.HMDOnlyMouseRotateEnable] = true; dictionary[ConfigVRCtrl.TypeItem.HMDOnlyMouseRotateSpeed] = true; } else if (vrdeviceTypeID == GameMain.VRDeviceType.FOVE) { dictionary[ConfigVRCtrl.TypeItem.HMDOnlyCameraPlaneMovement] = true; dictionary[ConfigVRCtrl.TypeItem.HMDOnlyMouseRotateEnable] = true; dictionary[ConfigVRCtrl.TypeItem.HMDOnlyMouseRotateSpeed] = true; } else if (vrdeviceTypeID == GameMain.VRDeviceType.VIVE) { dictionary[ConfigVRCtrl.TypeItem.ViveFloorHeightType] = true; dictionary[ConfigVRCtrl.TypeItem.ViveMoveMode] = true; dictionary[ConfigVRCtrl.TypeItem.ViveSnapRotateEnable] = (this.cmSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.WARP_DRAW_STEPROT); dictionary[ConfigVRCtrl.TypeItem.ViveSnapRotateRate] = (this.cmSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.WARP_DRAW_STEPROT); dictionary[ConfigVRCtrl.TypeItem.ViveOldRotatePad] = (this.cmSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.DIRECTION); dictionary[ConfigVRCtrl.TypeItem.ViveOldMovePad] = (this.cmSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.DIRECTION); dictionary[ConfigVRCtrl.TypeItem.ViveOldMoveRotatePadAriaRate] = (this.cmSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.DIRECTION); dictionary[ConfigVRCtrl.TypeItem.ViveDDTouchToClick] = false; dictionary[ConfigVRCtrl.TypeItem.ViveOvrTabletFrameHideWhenMsgWndVisible] = true; } else if (vrdeviceTypeID == GameMain.VRDeviceType.RIFT_TOUCH) { dictionary[ConfigVRCtrl.TypeItem.TouchMoveMode] = true; dictionary[ConfigVRCtrl.TypeItem.TouchSnapRotateEnable] = (this.cmSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.WARP_DRAW_STEPROT); dictionary[ConfigVRCtrl.TypeItem.TouchSnapRotateRate] = (this.cmSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.WARP_DRAW_STEPROT); dictionary[ConfigVRCtrl.TypeItem.TouchOldRotateStick] = (this.cmSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.DIRECTION); dictionary[ConfigVRCtrl.TypeItem.TouchOldMoveStick] = (this.cmSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.DIRECTION); dictionary[ConfigVRCtrl.TypeItem.TouchDDTouchToClick] = false; dictionary[ConfigVRCtrl.TypeItem.TouchOvrTabletFrameHideWhenMsgWndVisible] = true; } dictionary[ConfigVRCtrl.TypeItem.DummyShowMan] = false; foreach (KeyValuePair keyValuePair in dictionary) { this.dicItem[keyValuePair.Key].gameObject.SetActive(keyValuePair.Value); } UIGrid cache = base.cachedObjectDic.GetCache("Parent Grid"); cache.Reposition(); } private void SetItemShowFlag(ConfigVRCtrl.TypeItem type, bool isShow) { if (this.dicItem == null) { Debug.Log("[ConfigVRCtrl] まだ項目の初期化は行っていません"); return; } if (this.dicItem[type].gameObject.activeSelf == isShow) { return; } this.dicItem[type].gameObject.SetActive(isShow); UIGrid cache = base.cachedObjectDic.GetCache("Parent Grid"); cache.Reposition(); } private void LoadConfigData() { if (this.dicItem == null) { Debug.Log("[ConfigVRCtrl] まだ項目の初期化は行っていません"); return; } foreach (KeyValuePair keyValuePair in this.dicItem) { switch (keyValuePair.Key) { case ConfigVRCtrl.TypeItem.CommonEyeHeight: keyValuePair.Value.Set(this.cmSystem.VRCameraHeightStand); break; case ConfigVRCtrl.TypeItem.CommonSitHeight: keyValuePair.Value.Set(this.cmSystem.VRCameraHeightSit); break; case ConfigVRCtrl.TypeItem.CommonCameraMoveSpeed: keyValuePair.Value.Set(this.cmSystem.VRCameraMoveSpeedKey); break; case ConfigVRCtrl.TypeItem.CommonCameraRotSpeed: keyValuePair.Value.Set(this.cmSystem.VRCameraRotSpeedKey); break; case ConfigVRCtrl.TypeItem.CommonShowDesktopScreen: keyValuePair.Value.Set(GameMain.Instance.BgMgr.isShowDesktopScreen); break; case ConfigVRCtrl.TypeItem.ViveFloorHeightType: keyValuePair.Value.Set(this.cmSystem.OvrCameraHeightType == CMSystem.OVR_CAM_HEIGHT_TYPE.REAL); break; case ConfigVRCtrl.TypeItem.ViveSnapRotateEnable: keyValuePair.Value.Set(this.cmSystem.OvrUseSnapRotate); break; case ConfigVRCtrl.TypeItem.ViveSnapRotateRate: keyValuePair.Value.Set((float)this.cmSystem.OvrUseSnapRotateRate); break; case ConfigVRCtrl.TypeItem.ViveMoveMode: keyValuePair.Value.Set(this.cmSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.WARP_DRAW_STEPROT); break; case ConfigVRCtrl.TypeItem.ViveOldRotatePad: keyValuePair.Value.Set(this.cmSystem.SConfig.OvrViveSmoothRotatePadAreaUse); break; case ConfigVRCtrl.TypeItem.ViveOldMovePad: keyValuePair.Value.Set(this.cmSystem.SConfig.OvrViveSmoothupDownPadAreaUse); break; case ConfigVRCtrl.TypeItem.ViveOldMoveRotatePadAriaRate: keyValuePair.Value.Set(this.cmSystem.SConfig.OvrViveSmoothRotatePadAriaRate); break; case ConfigVRCtrl.TypeItem.ViveDDTouchToClick: keyValuePair.Value.Set(this.cmSystem.SConfig.OvrDDTouchToClick); break; case ConfigVRCtrl.TypeItem.ViveOvrTabletFrameHideWhenMsgWndVisible: keyValuePair.Value.Set(this.cmSystem.SConfig.OvrTabletFrameHideWhenMsgWndVisible); break; case ConfigVRCtrl.TypeItem.TouchSnapRotateEnable: keyValuePair.Value.Set(this.cmSystem.OvrUseSnapRotate); break; case ConfigVRCtrl.TypeItem.TouchSnapRotateRate: keyValuePair.Value.Set((float)this.cmSystem.OvrUseSnapRotateRate); break; case ConfigVRCtrl.TypeItem.TouchMoveMode: keyValuePair.Value.Set(this.cmSystem.SConfig.OvrMoveType == CMSystem.SerializeConfig.OVR_MOVE_TYPE.WARP_DRAW_STEPROT); break; case ConfigVRCtrl.TypeItem.TouchOldRotateStick: keyValuePair.Value.Set(this.cmSystem.SConfig.OvrRiftGripStickRotate); break; case ConfigVRCtrl.TypeItem.TouchOldMoveStick: keyValuePair.Value.Set(this.cmSystem.SConfig.OvrRiftTriggerStickUpDown); break; case ConfigVRCtrl.TypeItem.TouchDDTouchToClick: keyValuePair.Value.Set(this.cmSystem.SConfig.OvrDDTouchToClick); break; case ConfigVRCtrl.TypeItem.TouchOvrTabletFrameHideWhenMsgWndVisible: keyValuePair.Value.Set(this.cmSystem.SConfig.OvrTabletFrameHideWhenMsgWndVisible); break; case ConfigVRCtrl.TypeItem.HMDOnlyCameraPlaneMovement: keyValuePair.Value.Set(this.cmSystem.VRCameraPlaneMove); break; case ConfigVRCtrl.TypeItem.HMDOnlyMouseRotateEnable: keyValuePair.Value.Set(this.cmSystem.OvrMouseRot); break; case ConfigVRCtrl.TypeItem.HMDOnlyMouseRotateSpeed: keyValuePair.Value.Set(this.cmSystem.VRCameraRotSpeedMouse); break; case ConfigVRCtrl.TypeItem.DummyMouseRotateSpeed: keyValuePair.Value.Set(this.cmSystem.VRCameraRotSpeedMouse); break; case ConfigVRCtrl.TypeItem.DummyMouseRotateInverse: keyValuePair.Value.Set(this.cmSystem.VRCamRotDownUp); break; case ConfigVRCtrl.TypeItem.DummyCameraPlaneMovement: keyValuePair.Value.Set(this.cmSystem.VRCameraPlaneMove); break; case ConfigVRCtrl.TypeItem.DummyShowMan: keyValuePair.Value.Set(this.cmSystem.VRManShow); break; case ConfigVRCtrl.TypeItem.DummyCameraFov: keyValuePair.Value.Set(this.cmSystem.VRCameraFov); break; default: Debug.LogError("[ConfigVRCtrl] 種類「" + keyValuePair.Key + "」のセッターがない"); NDebug.Assert("[ConfigVRCtrl] 種類「" + keyValuePair.Key + "」のセッターがない", false); break; } } } private void OnApplicationQuit() { this.m_IsQuittingApplication = true; } private void OnDestroy() { if (this.m_IsQuittingApplication) { return; } if (ConfigVRCtrl.instance != null && ConfigVRCtrl.instance == this) { ConfigVRCtrl.m_Instance = null; } if (this.dicItem != null) { this.dicItem.Clear(); this.dicItem = null; } this.onClickOK = null; } private static ConfigVRCtrl m_Instance; private static readonly Vector2 COMMON_EYE_HEIGHT_VALUE = new Vector2(1.5f, 1.8f); private static readonly Vector2 COMMON_SITTING_HEIGHT_VALUE = new Vector2(0.7f, 1f); private static readonly Vector2 COMMON_CAMERA_MOVE_VALUE = new Vector2(0f, 1f); private static readonly Vector2 COMMON_CAMERA_ROT_VALUE = new Vector2(0f, 1f); private static readonly Vector2 VR_CAMERA_SNAP_ROT_VALUE = new Vector2(10f, 80f); private static readonly Vector2 VR_CAMERA_MOUSE_ROT_VALUE = new Vector2(0f, 1f); private static readonly Vector2 VR2D_CAMERA_FOV_VALUE = new Vector2(30f, 60f); private Dictionary m_DicItem; private bool m_IsQuittingApplication; private abstract class ParentItem : MonoBehaviour { public UILabel label { get { return this.m_Label; } } protected virtual void Awake() { this.m_Label = UTY.GetChildObject(base.gameObject, "name", false).GetComponent(); if (this.m_Label == null) { string message = "[ConfigVRCtrl] " + base.gameObject.name + "/nameに、\nUILabel のコンポーネントがありませんでした"; NDebug.Assert(message, false); Debug.LogError(message); } } public abstract void Set(object value); private UILabel m_Label; } private class ParentSlider : ConfigVRCtrl.ParentItem { public UISlider slider { get { return this.m_Slider; } private set { this.m_Slider = value; } } public float normalizedValue { get { return this.slider.value; } set { this.slider.value = value; } } public float min { get { return this.m_Min; } set { this.m_Min = value; } } public float max { get { return this.m_Max; } set { this.m_Max = value; } } public float value { get { return Mathf.Lerp(this.min, this.max, this.normalizedValue); } set { this.normalizedValue = Mathf.InverseLerp(this.min, this.max, value); } } public Action onValueChanged { get; set; } public Action onDragFinished { get; set; } protected override void Awake() { base.Awake(); GameObject childObject = UTY.GetChildObject(base.gameObject, "slider", false); this.slider = childObject.GetComponent(); if (this.slider == null) { string message = string.Concat(new string[] { "[ConfigVRCtrl] ", base.gameObject.name, "/", childObject.name, "に、\nUISlider のコンポーネントがありませんでした" }); NDebug.Assert(message, false); Debug.LogError(message); } EventDelegate.Add(this.slider.onChange, delegate() { if (this.onValueChanged != null) { this.onValueChanged(this.value); } }); UISlider slider = this.slider; slider.onDragFinished = (UIProgressBar.OnDragFinished)Delegate.Combine(slider.onDragFinished, new UIProgressBar.OnDragFinished(delegate() { if (this.onDragFinished != null) { this.onDragFinished(); } })); } public override void Set(object value) { this.value = (float)value; } private UISlider m_Slider; private float m_Min; private float m_Max = 1f; } private class ParentButton : ConfigVRCtrl.ParentItem { public UIButton buttonRight { get { return this.m_ButtonRight; } private set { this.m_ButtonRight = value; } } public UIButton buttonLeft { get { return this.m_ButtonLeft; } private set { this.m_ButtonLeft = value; } } public Action onClickIsLeft { get; set; } protected override void Awake() { base.Awake(); GameObject childObject = UTY.GetChildObject(base.gameObject, "button right", false); this.buttonRight = childObject.GetComponent(); if (this.buttonRight == null) { string message = string.Concat(new string[] { "[ConfigVRCtrl] ", base.gameObject.name, "/", childObject.name, "に、\nUIButton のコンポーネントがありませんでした" }); NDebug.Assert(message, false); Debug.LogError(message); } childObject = UTY.GetChildObject(base.gameObject, "button left", false); this.buttonLeft = childObject.GetComponent(); if (this.buttonLeft == null) { string message2 = string.Concat(new string[] { "[ConfigVRCtrl] ", base.gameObject.name, "/", childObject.name, "に、\nUIButton のコンポーネントがありませんでした" }); NDebug.Assert(message2, false); Debug.LogError(message2); } EventDelegate.Add(this.buttonRight.onClick, delegate() { if (this.onClickIsLeft != null) { this.onClickIsLeft(false); } this.OnClickButton(false); }); EventDelegate.Add(this.buttonLeft.onClick, delegate() { if (this.onClickIsLeft != null) { this.onClickIsLeft(true); } this.OnClickButton(true); }); } private void OnClickButton(bool isLeft) { this.buttonLeft.defaultColor = ((!isLeft) ? ConfigVRCtrl.ParentButton.ButtonDefaultColor : ConfigVRCtrl.ParentButton.ButtonClickedColor); this.buttonRight.defaultColor = (isLeft ? ConfigVRCtrl.ParentButton.ButtonDefaultColor : ConfigVRCtrl.ParentButton.ButtonClickedColor); } public void Emulate(bool isLeft) { UIButton uibutton = (!isLeft) ? this.buttonRight : this.buttonLeft; EventDelegate.Execute(uibutton.onClick); } public override void Set(object value) { this.Emulate((bool)value); } private static Color ButtonDefaultColor = new Color(1f, 1f, 1f, 0.5f); private static Color ButtonClickedColor = Color.white; private UIButton m_ButtonRight; private UIButton m_ButtonLeft; } private enum TypeItem { CommonEyeHeight, CommonSitHeight, CommonCameraMoveSpeed, CommonCameraRotSpeed, CommonShowDesktopScreen, ViveFloorHeightType, ViveSnapRotateEnable, ViveSnapRotateRate, ViveMoveMode, ViveOldRotatePad, ViveOldMovePad, ViveOldMoveRotatePadAriaRate, ViveDDTouchToClick, ViveOvrTabletFrameHideWhenMsgWndVisible, TouchSnapRotateEnable, TouchSnapRotateRate, TouchMoveMode, TouchOldRotateStick, TouchOldMoveStick, TouchDDTouchToClick, TouchOvrTabletFrameHideWhenMsgWndVisible, HMDOnlyCameraPlaneMovement, HMDOnlyMouseRotateEnable, HMDOnlyMouseRotateSpeed, DummyMouseRotateSpeed, DummyMouseRotateInverse, DummyCameraPlaneMovement, DummyShowMan, DummyCameraFov } }