1
0
mirror of https://github.com/xiaopeng12138/MaiDXR.git synced 2025-01-05 19:34:32 +01:00
MaiDXR/Assets/Scripts/Configurations/NoneVRSettingManager.cs

120 lines
3.3 KiB
C#
Raw Normal View History

2022-08-17 18:58:08 +02:00
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class NoneVRSettingManager : MonoBehaviour
{
2022-08-17 23:15:59 +02:00
public GameObject NVRCameraObj;
public Camera NVRCamera;
public Transform NVRCameraTargetFP;
public Transform NVRCameraTargetTP;
public CameraSmooth CameraSmooth;
2022-08-17 18:58:08 +02:00
private TMP_Dropdown Dropdown;
private Slider Slider;
void Start()
{
Dropdown = GetComponent<TMP_Dropdown>();
Slider = GetComponent<Slider>();
switch (gameObject.name)
{
case "NVRModeDropdown":
2022-08-17 23:15:59 +02:00
GetNVRMode();
2022-08-17 18:58:08 +02:00
break;
case "NVRFOV":
2022-08-17 23:15:59 +02:00
GetNVRFOV();
2022-08-17 18:58:08 +02:00
break;
case "NVRFPSDropdown":
2022-08-17 23:15:59 +02:00
GetNVRFPS();
break;
case "TPCameraCube":
GetTPCamTransform();
2022-08-17 18:58:08 +02:00
break;
}
}
public void GetNVRMode()
{
if (JsonConfig.HasKey("NVRMode"))
Dropdown.value = JsonConfig.GetInt("NVRMode");
SetNVRMode();
}
public void GetNVRFOV()
{
if (JsonConfig.HasKey("NVRFOV"))
Slider.value = (float)JsonConfig.GetDouble("NVRFOV");
2022-08-17 23:15:59 +02:00
SetNVRFOV(Slider.value);
2022-08-17 18:58:08 +02:00
}
2022-08-17 23:15:59 +02:00
public void GetNVRFPS()
2022-08-17 18:58:08 +02:00
{
if (JsonConfig.HasKey("NVRFPS"))
Dropdown.value = JsonConfig.GetInt("NVRFPS");
2022-08-17 23:15:59 +02:00
SetNVRFPS();
}
public void GetTPCamTransform()
{
if (JsonConfig.HasKey("TPCamPosition"))
gameObject.transform.position = JsonConfig.GetVector3("TPCamPosition");
if (JsonConfig.HasKey("TPCamRotation"))
gameObject.transform.rotation = JsonConfig.GetQuaternion("TPCamRotation");
SetTPCamTransform();
2022-08-17 18:58:08 +02:00
}
public void SetNVRMode()
{
switch (Dropdown.value)
{
case 0:
2022-08-17 23:15:59 +02:00
NVRCameraObj.SetActive(false);
2022-08-17 18:58:08 +02:00
break;
case 1:
2022-08-17 23:15:59 +02:00
NVRCameraObj.SetActive(true);
CameraSmooth.target = NVRCameraTargetFP;
2022-08-17 18:58:08 +02:00
break;
case 2:
2022-08-17 23:15:59 +02:00
NVRCameraObj.SetActive(true);
CameraSmooth.target = NVRCameraTargetTP;
2022-08-17 18:58:08 +02:00
break;
}
JsonConfig.SetInt("NVRMode", Dropdown.value);
}
2022-08-17 23:15:59 +02:00
public void SetNVRFOV(float fov)
2022-08-17 18:58:08 +02:00
{
2022-08-17 23:15:59 +02:00
NVRCamera.fieldOfView = fov;
JsonConfig.SetDouble("NVRFOV", fov);
2022-08-17 18:58:08 +02:00
}
2022-08-17 23:15:59 +02:00
public void SetNVRFPS()
2022-08-17 18:58:08 +02:00
{
switch (Dropdown.value)
{
case 0:
CameraSmooth.FPS = 15;
break;
case 1:
CameraSmooth.FPS = 30;
break;
case 2:
CameraSmooth.FPS = 45;
break;
case 3:
CameraSmooth.FPS = 60;
break;
case 4:
CameraSmooth.FPS = 90;
break;
case 5:
CameraSmooth.FPS = 120;
break;
case 6:
CameraSmooth.FPS = 144;
break;
}
JsonConfig.SetInt("NVRFPS", Dropdown.value);
}
2022-08-17 23:15:59 +02:00
public void SetTPCamTransform()
{
JsonConfig.SetVector3("TPCamPosition", gameObject.transform.position);
JsonConfig.SetQuaternion("TPCamRotation", gameObject.transform.rotation);
}
2022-08-17 18:58:08 +02:00
}