2022-08-17 18:58:08 +02:00
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
2022-08-25 23:31:20 +02:00
|
|
|
using Newtonsoft.Json.Linq;
|
2022-08-17 18:58:08 +02:00
|
|
|
|
|
|
|
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");
|
2022-08-27 00:17:18 +02:00
|
|
|
if (JsonConfig.HasKey("NVRCameraSmooth"))
|
|
|
|
CameraSmooth.smoothSpeed = JsonConfig.GetInt("NVRCameraSmooth");
|
2022-08-17 18:58:08 +02:00
|
|
|
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
|
|
|
{
|
2022-08-18 23:17:30 +02:00
|
|
|
QualitySettings.vSyncCount = 0;
|
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-18 23:17:30 +02:00
|
|
|
if (NVRCameraObj.activeSelf)
|
|
|
|
NVRCameraObj.SetActive(false);
|
2022-08-17 18:58:08 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2022-08-18 23:17:30 +02:00
|
|
|
if (!NVRCameraObj.activeSelf)
|
|
|
|
NVRCameraObj.SetActive(true);
|
2022-08-17 23:15:59 +02:00
|
|
|
CameraSmooth.target = NVRCameraTargetFP;
|
2022-08-27 00:04:14 +02:00
|
|
|
NVRCamera.cullingMask |= 1 << LayerMask.NameToLayer("FPSBlock"); // Enable FPBlock
|
|
|
|
NVRCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("TPSBlock")); // Disable TPBlock
|
2022-08-17 18:58:08 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2022-08-18 23:17:30 +02:00
|
|
|
if (!NVRCameraObj.activeSelf)
|
|
|
|
NVRCameraObj.SetActive(true);
|
2022-08-17 23:15:59 +02:00
|
|
|
CameraSmooth.target = NVRCameraTargetTP;
|
2022-08-27 00:04:14 +02:00
|
|
|
NVRCamera.cullingMask |= 1 << LayerMask.NameToLayer("TPSBlock"); // Enable TPBlock
|
|
|
|
NVRCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("FPSBlock")); // Disable FPBlock
|
2022-08-17 18:58:08 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
JsonConfig.SetInt("NVRMode", Dropdown.value);
|
2022-08-27 00:17:18 +02:00
|
|
|
JsonConfig.SetInt("NVRCameraSmooth", Dropdown.value);
|
2022-08-17 18:58:08 +02:00
|
|
|
}
|
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:
|
2022-08-18 23:17:30 +02:00
|
|
|
Application.targetFrameRate = 15;
|
2022-08-17 18:58:08 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2022-08-18 23:17:30 +02:00
|
|
|
Application.targetFrameRate = 30;
|
2022-08-17 18:58:08 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2022-08-18 23:17:30 +02:00
|
|
|
Application.targetFrameRate = 45;
|
2022-08-17 18:58:08 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2022-08-18 23:17:30 +02:00
|
|
|
Application.targetFrameRate = 60;
|
2022-08-17 18:58:08 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2022-08-18 23:17:30 +02:00
|
|
|
Application.targetFrameRate = 90;
|
2022-08-17 18:58:08 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
2022-08-18 23:17:30 +02:00
|
|
|
Application.targetFrameRate = 120;
|
2022-08-17 18:58:08 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
2022-08-18 23:17:30 +02:00
|
|
|
Application.targetFrameRate = 144;
|
2022-08-17 18:58:08 +02:00
|
|
|
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
|
|
|
}
|