1296 lines
38 KiB
C#
1296 lines
38 KiB
C#
using System;
|
|
using System.Collections;
|
|
using BitStrap;
|
|
using LIV.SDK.Unity;
|
|
using Rewired.Integration.UnityUI;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.XR;
|
|
using UnityStandardAssets.ImageEffects;
|
|
using VRKeyboard.Utils;
|
|
|
|
public class VRManager : MonoBehaviour
|
|
{
|
|
public enum UIInputStyle
|
|
{
|
|
GAZE = 0,
|
|
POINTER = 1,
|
|
NONE = 2
|
|
}
|
|
|
|
public enum PlayerRotateStyle
|
|
{
|
|
FREE = 0,
|
|
STEP = 1,
|
|
FADE_STEP = 2
|
|
}
|
|
|
|
public enum PlayerWalkStyle
|
|
{
|
|
FREE = 0,
|
|
GAZE_TELEPORT = 1,
|
|
POINTER_TELEPORT = 2
|
|
}
|
|
|
|
public enum TeleportStyle
|
|
{
|
|
INSTANT = 0,
|
|
FADE = 1,
|
|
WARP = 2
|
|
}
|
|
|
|
public enum HUDRotateStyle
|
|
{
|
|
NONE = 0,
|
|
FREE = 1,
|
|
STEP = 2
|
|
}
|
|
|
|
private static VRManager instance;
|
|
|
|
public string startDevice = string.Empty;
|
|
|
|
public string commandLineTest = string.Empty;
|
|
|
|
private static bool isVROn;
|
|
|
|
public static bool useOculusSDK;
|
|
|
|
public static bool initialized;
|
|
|
|
public bool useOculusSDKPublic;
|
|
|
|
public bool forceVRQuality;
|
|
|
|
[ReadOnly]
|
|
public float currentEyeResolutionScale = 1f;
|
|
|
|
public LIV.SDK.Unity.LIV liv;
|
|
|
|
public bool isOculusDashboardOn;
|
|
|
|
[Header("Menu")]
|
|
public GameObject uiController;
|
|
|
|
public GameObject vrPlayer;
|
|
|
|
public OvrAvatar ovrAvatar;
|
|
|
|
public float menuSize;
|
|
|
|
public float hudSize;
|
|
|
|
[ReadOnly]
|
|
public float hudSizeStartMultiplier;
|
|
|
|
public Vector2 menuSizeMinMax = Vector2.zero;
|
|
|
|
public Vector2 hudSizeMinMax = Vector2.zero;
|
|
|
|
public bool useCurvedUI = true;
|
|
|
|
public int curvedUIAngle = 70;
|
|
|
|
private Transform curvedUIPointer;
|
|
|
|
public KeyboardManager keyboardManager;
|
|
|
|
[Header("UI Input")]
|
|
public Transform eyeCenterTransform;
|
|
|
|
public GameObject gazeInputParent;
|
|
|
|
public GameObject pointerInputParent;
|
|
|
|
public UIInputStyle uIInputStyle;
|
|
|
|
public GameObject menuEnviroParent;
|
|
|
|
[Header("Player")]
|
|
public float turnAngle = 45f;
|
|
|
|
public float freeTurnSpeed = 45f;
|
|
|
|
public float fadeDuration = 0.5f;
|
|
|
|
public float cameraHeight;
|
|
|
|
public PlayerRotateStyle playerRotateStyle = PlayerRotateStyle.STEP;
|
|
|
|
public PlayerWalkStyle playerWalkStyle;
|
|
|
|
public TeleportStyle teleportStyle;
|
|
|
|
public HUDRotateStyle hudRotateStyle;
|
|
|
|
public bool showAfpsCounter;
|
|
|
|
public bool playerFollowCamera = true;
|
|
|
|
[Header("Gameplay")]
|
|
public bool vrReeling = true;
|
|
|
|
public bool vrAutoReelgGrip = true;
|
|
|
|
public bool vrGroundbait = true;
|
|
|
|
public bool vrHoldRod = true;
|
|
|
|
public bool vrDrilling = true;
|
|
|
|
public bool vrFishingNet = true;
|
|
|
|
public bool vrDriveBoat = true;
|
|
|
|
public bool vrComfortableDriveBoat = true;
|
|
|
|
public bool vrCastOnPress;
|
|
|
|
public OVRInput.Controller prevController;
|
|
|
|
public OVRInput.Controller currentController;
|
|
|
|
public float tempShadowDistance = -1f;
|
|
|
|
[ReadOnly]
|
|
public bool isWeaponLayerOn = true;
|
|
|
|
public static VRManager Instance
|
|
{
|
|
get
|
|
{
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private VRManager()
|
|
{
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
|
|
isVROn = XRSettings.enabled && XRSettings.loadedDeviceName != string.Empty && XRSettings.loadedDeviceName != "None";
|
|
if ((bool)liv)
|
|
{
|
|
UnityEngine.Object.DestroyImmediate(liv);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UnityEngine.Object.DestroyImmediate(base.gameObject);
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
ShowXRInfo();
|
|
ShowInputInfo();
|
|
if (startDevice != string.Empty)
|
|
{
|
|
StartCoroutine(LoadDevice(startDevice));
|
|
}
|
|
useOculusSDK = XRSettings.loadedDeviceName == "Oculus";
|
|
useOculusSDKPublic = useOculusSDK;
|
|
currentEyeResolutionScale = XRSettings.eyeTextureResolutionScale;
|
|
RefreshEyeTextureResolutionScale(GlobalSettings.Instance);
|
|
if (!IsVROn() || (bool)GameController.Instance)
|
|
{
|
|
Instance.TurnOnUIController(false);
|
|
}
|
|
isVROn = XRSettings.enabled && XRSettings.loadedDeviceName != string.Empty && XRSettings.loadedDeviceName != "None";
|
|
if (isVROn)
|
|
{
|
|
}
|
|
HideKeyboard();
|
|
OVRManager.HMDMounted += OnHeadsetMount;
|
|
OVRManager.HMDUnmounted += OnHeadsetUnmount;
|
|
initialized = true;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
OVRManager.HMDMounted -= OnHeadsetMount;
|
|
OVRManager.HMDUnmounted -= OnHeadsetUnmount;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
isVROn = XRSettings.enabled && XRSettings.loadedDeviceName != string.Empty && XRSettings.loadedDeviceName != "None";
|
|
UpdateControllerInput();
|
|
if (isVROn)
|
|
{
|
|
if (OVRManager.hasInputFocus && isOculusDashboardOn)
|
|
{
|
|
OculusDashboardShown(false);
|
|
}
|
|
else if (!OVRManager.hasInputFocus && !isOculusDashboardOn)
|
|
{
|
|
OculusDashboardShown(true);
|
|
}
|
|
}
|
|
if ((bool)GlobalSettings.Instance && !GlobalSettings.Instance.turnOnMyCheats)
|
|
{
|
|
return;
|
|
}
|
|
if (Input.GetKey(KeyCode.Home))
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Alpha0))
|
|
{
|
|
Screen.SetResolution(1920, 1080, true);
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Alpha8))
|
|
{
|
|
ToggleEyeTextureResolutionScale();
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Alpha7))
|
|
{
|
|
forceVRQuality = !forceVRQuality;
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
GlobalSettings.Instance.renderSettings.RefreshSettings();
|
|
}
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Alpha4))
|
|
{
|
|
ToggleLODMax();
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Alpha5))
|
|
{
|
|
ToggleLODBias();
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Alpha6))
|
|
{
|
|
ToggleDOF();
|
|
}
|
|
}
|
|
if ((bool)MenuManager.Instance && MenuManager.Instance.gameObject.activeSelf && OVRInput.GetDown(OVRInput.Button.PrimaryHandTrigger))
|
|
{
|
|
ChangeUIInputStyle((uIInputStyle == UIInputStyle.GAZE) ? UIInputStyle.POINTER : UIInputStyle.GAZE);
|
|
}
|
|
}
|
|
|
|
public void CheckCommandLineSDK()
|
|
{
|
|
string[] commandLineArgs = Environment.GetCommandLineArgs();
|
|
Debug.Log("GetCommandLineArgs " + commandLineArgs.Length);
|
|
for (int i = 0; i < commandLineArgs.Length; i++)
|
|
{
|
|
Debug.Log("arg " + commandLineArgs[i]);
|
|
if (commandLineArgs[i] == "-OculusSDK" && XRSettings.loadedDeviceName != "Oculus")
|
|
{
|
|
StartCoroutine(LoadDevice("Oculus"));
|
|
}
|
|
else if (commandLineArgs[i] == "-SteamVR" && XRSettings.loadedDeviceName != "OpenVR")
|
|
{
|
|
StartCoroutine(LoadDevice("OpenVR"));
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ChangeUIInputStyle(UIInputStyle newStyle)
|
|
{
|
|
Debug.Log("ChangeUIInputStyle 1: " + newStyle);
|
|
if (!Instance.IsControllersInput())
|
|
{
|
|
newStyle = UIInputStyle.GAZE;
|
|
}
|
|
Debug.Log("ChangeUIInputStyle 2: " + newStyle);
|
|
uIInputStyle = newStyle;
|
|
gazeInputParent.SetActive(newStyle == UIInputStyle.GAZE);
|
|
pointerInputParent.SetActive(newStyle == UIInputStyle.POINTER);
|
|
gazeInputParent.GetComponentInChildren<OVRGazePointer>(true).gameObject.SetActive(newStyle == UIInputStyle.GAZE);
|
|
pointerInputParent.GetComponentInChildren<LaserPointer>(true).gameObject.SetActive(newStyle == UIInputStyle.POINTER);
|
|
switch (newStyle)
|
|
{
|
|
case UIInputStyle.GAZE:
|
|
gazeInputParent.GetComponentInChildren<OVRInputModule>(true).rayTransform = eyeCenterTransform;
|
|
gazeInputParent.GetComponentInChildren<OVRGazePointer>(true).rayTransform = eyeCenterTransform;
|
|
break;
|
|
}
|
|
if (uIInputStyle == UIInputStyle.GAZE)
|
|
{
|
|
curvedUIPointer = gazeInputParent.GetComponentInChildren<OVRInputModule>(true).rayTransform;
|
|
}
|
|
else
|
|
{
|
|
curvedUIPointer = pointerInputParent.GetComponentInChildren<OVRInputModule>(true).rayTransform;
|
|
}
|
|
}
|
|
|
|
public void HideGazeAndPointer()
|
|
{
|
|
gazeInputParent.GetComponentInChildren<OVRGazePointer>(true).gameObject.SetActive(false);
|
|
pointerInputParent.GetComponentInChildren<LaserPointer>(true).gameObject.SetActive(false);
|
|
}
|
|
|
|
public void InitializeMainMenu()
|
|
{
|
|
bool flag = IsVROn();
|
|
vrPlayer.SetActive(flag);
|
|
if (!flag || !GlobalSettings.Instance)
|
|
{
|
|
ChangeUIInputStyle(UIInputStyle.NONE);
|
|
SetCurvedUI(false, true);
|
|
}
|
|
else
|
|
{
|
|
Instance.TurnOnUIController(true);
|
|
Instance.ShowMenuEnviro(true);
|
|
ChangeUIInputStyle(UIInputStyle.POINTER);
|
|
if ((bool)MenuManager.Instance)
|
|
{
|
|
MenuManager.Instance.transform.localScale = Vector3.one * 0.15f;
|
|
Canvas[] componentsInChildren = MenuManager.Instance.GetComponentsInChildren<Canvas>(true);
|
|
for (int i = 0; i < componentsInChildren.Length; i++)
|
|
{
|
|
if (componentsInChildren[i].gameObject.name == "DropdownContent")
|
|
{
|
|
componentsInChildren[i].GetComponent<OVRRaycaster>().pointer = gazeInputParent.GetComponentInChildren<OVRGazePointer>(true).gameObject;
|
|
continue;
|
|
}
|
|
componentsInChildren[i].renderMode = RenderMode.WorldSpace;
|
|
componentsInChildren[i].worldCamera = eyeCenterTransform.GetComponent<Camera>();
|
|
RectTransform component = componentsInChildren[i].GetComponent<RectTransform>();
|
|
component.anchoredPosition3D = Vector3.zero;
|
|
component.localRotation = Quaternion.identity;
|
|
component.localScale = Vector3.one * 0.03f;
|
|
component.sizeDelta = new Vector2(1225f, 700f);
|
|
component.pivot = Vector2.one * 0.5f;
|
|
OVRRaycaster oVRRaycaster = componentsInChildren[i].gameObject.AddComponent<OVRRaycaster>();
|
|
oVRRaycaster.pointer = gazeInputParent.GetComponentInChildren<OVRGazePointer>(true).gameObject;
|
|
}
|
|
}
|
|
if ((bool)TutorialManager.Instance && (bool)MenuManager.Instance)
|
|
{
|
|
TutorialManager.Instance.transform.position = MenuManager.Instance.transform.position + Vector3.back * 0.5f;
|
|
TutorialManager.Instance.GetComponentInChildren<Camera>().gameObject.SetActive(false);
|
|
Canvas componentInChildren = TutorialManager.Instance.GetComponentInChildren<Canvas>(true);
|
|
componentInChildren.renderMode = RenderMode.WorldSpace;
|
|
componentInChildren.worldCamera = eyeCenterTransform.GetComponent<Camera>();
|
|
componentInChildren.GetComponent<CanvasScaler>().dynamicPixelsPerUnit = 3f;
|
|
RectTransform component2 = componentInChildren.GetComponent<RectTransform>();
|
|
component2.anchoredPosition3D = Vector3.zero;
|
|
component2.localRotation = Quaternion.identity;
|
|
component2.localScale = Vector3.one * 0.0045f;
|
|
OVRRaycaster oVRRaycaster2 = componentInChildren.gameObject.AddComponent<OVRRaycaster>();
|
|
oVRRaycaster2.pointer = gazeInputParent.GetComponentInChildren<OVRGazePointer>(true).gameObject;
|
|
oVRRaycaster2.sortOrder = 2000;
|
|
if ((bool)TutorialManager.Instance.buildInfoParent)
|
|
{
|
|
TutorialManager.Instance.buildInfoParent.localPosition = new Vector3(-190f, -418f, 109f);
|
|
TutorialManager.Instance.buildInfoParent.localScale = Vector3.one;
|
|
}
|
|
}
|
|
SetCurvedUI(useCurvedUI);
|
|
}
|
|
OVRInput.UpdateXRControllerNodeIds(true);
|
|
}
|
|
|
|
public void FixTutorialPosition()
|
|
{
|
|
if (IsVROn())
|
|
{
|
|
if ((bool)GameController.Instance && !MenuManager.Instance.gameObject.activeSelf)
|
|
{
|
|
Vector3 position = GameController.Instance.fishingPlayer.ufpsCamera.transform.position;
|
|
position += GameController.Instance.fishingPlayer.GetForwardVector() * 1f;
|
|
TutorialManager.Instance.transform.position = position;
|
|
TutorialManager.Instance.transform.eulerAngles = new Vector3(0f, GameController.Instance.fishingPlayer.ufpsCamera.transform.eulerAngles.y, 0f);
|
|
TutorialManager.Instance.transform.localScale = Vector3.one * 0.3f;
|
|
}
|
|
else
|
|
{
|
|
TutorialManager.Instance.transform.position = MenuManager.Instance.transform.position + Vector3.back * 0.5f;
|
|
TutorialManager.Instance.transform.rotation = Quaternion.identity;
|
|
TutorialManager.Instance.transform.localScale = Vector3.one;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void FixBugReportPosition(Transform bugReport)
|
|
{
|
|
if ((bool)GameController.Instance && !MenuManager.Instance.gameObject.activeSelf)
|
|
{
|
|
bugReport.GetComponent<RectTransform>().sizeDelta = new Vector2(800f, 600f);
|
|
Vector3 position = GameController.Instance.fishingPlayer.ufpsCamera.transform.position;
|
|
position += GameController.Instance.fishingPlayer.GetForwardVector() * 1f;
|
|
bugReport.position = position;
|
|
bugReport.transform.eulerAngles = new Vector3(0f, GameController.Instance.fishingPlayer.ufpsCamera.transform.eulerAngles.y, 0f);
|
|
bugReport.localScale = Vector3.one * 0.0018f;
|
|
bugReport.GetComponent<Canvas>().worldCamera = GameController.Instance.fishingPlayer.ufpsCameraCamera;
|
|
}
|
|
else
|
|
{
|
|
bugReport.GetComponent<RectTransform>().sizeDelta = new Vector2(800f, 600f);
|
|
bugReport.position = new Vector3(0f, 0f, -0.2f);
|
|
bugReport.rotation = Quaternion.identity;
|
|
bugReport.localScale = Vector3.one * 0.007f;
|
|
bugReport.GetComponent<Canvas>().worldCamera = eyeCenterTransform.GetComponent<Camera>();
|
|
}
|
|
}
|
|
|
|
public void InitializePlayer(FishingPlayer fishingPlayer)
|
|
{
|
|
if (IsVROn())
|
|
{
|
|
Debug.Log("VRManager InitializePlayer");
|
|
fishingPlayer.ufpsWeaponCamera.gameObject.SetActive(false);
|
|
fishingPlayer.hunterCamera.gameObject.SetActive(false);
|
|
fishingPlayer.amplifyMotionEffect.enabled = false;
|
|
fishingPlayer.depthOfField.enabled = false;
|
|
fishingPlayer.volumetricFog.enabled = false;
|
|
fishingPlayer.ufpsCamera.GetComponent<DeluxeEyeAdaptation>().enabled = false;
|
|
fishingPlayer.baitIndicatorCamera.gameObject.SetActive(false);
|
|
fishingPlayer.baitIndicatorCamera.transform.parent = fishingPlayer.ufpsCamera.transform.parent;
|
|
fishingPlayer.ufpsCameraCamera.cullingMask = Utilities.AddToLayerMask(fishingPlayer.ufpsCameraCamera.cullingMask, "Weapon");
|
|
fishingPlayer.ufpsCameraCamera.cullingMask = Utilities.AddToLayerMask(fishingPlayer.ufpsCameraCamera.cullingMask, "UI");
|
|
fishingPlayer.ufpsCameraCamera.cullingMask = Utilities.AddToLayerMask(fishingPlayer.ufpsCameraCamera.cullingMask, "UI3D");
|
|
fishingPlayer.ufpsCameraCamera.cullingMask = Utilities.AddToLayerMask(fishingPlayer.ufpsCameraCamera.cullingMask, "Debug");
|
|
fishingPlayer.ufpsCamera.enabled = false;
|
|
}
|
|
}
|
|
|
|
public void LateInitializePlayer(FishingPlayer fishingPlayer)
|
|
{
|
|
if (!IsVROn())
|
|
{
|
|
return;
|
|
}
|
|
Debug.Log("VRManager InitializePlayer");
|
|
vp_FPController component = fishingPlayer.GetComponent<vp_FPController>();
|
|
vp_FPWeapon[] componentsInChildren = fishingPlayer.ufpsCamera.gameObject.GetComponentsInChildren<vp_FPWeapon>();
|
|
vp_FPWeapon[] array = componentsInChildren;
|
|
foreach (vp_FPWeapon vp_FPWeapon2 in array)
|
|
{
|
|
vp_FPWeapon2.PositionPivotSpringDamping = 1f;
|
|
vp_FPWeapon2.PositionSpringDamping = 1f;
|
|
vp_FPWeapon2.PositionSpring2Damping = 1f;
|
|
vp_FPWeapon2.RotationPivotSpringDamping = 1f;
|
|
vp_FPWeapon2.RotationSpringDamping = 1f;
|
|
vp_FPWeapon2.RotationSpring2Damping = 1f;
|
|
vp_FPWeapon2.ShakeSpeed = 0f;
|
|
vp_FPWeapon2.ShakeAmplitude = Vector3.zero;
|
|
vp_FPWeapon2.BobRate = Vector4.zero;
|
|
vp_FPWeapon2.BobAmplitude = Vector4.zero;
|
|
vp_FPWeapon2.StepPositionForce = Vector3.zero;
|
|
vp_FPWeapon2.StepRotationForce = Vector3.zero;
|
|
vp_FPWeapon2.StepForceScale = 0f;
|
|
vp_FPWeapon2.Refresh();
|
|
}
|
|
foreach (FishingHands allFishingHand in fishingPlayer.allFishingHands)
|
|
{
|
|
allFishingHand.ToggleVRArmRenderers();
|
|
}
|
|
}
|
|
|
|
public static bool IsVROn()
|
|
{
|
|
if (initialized)
|
|
{
|
|
return isVROn;
|
|
}
|
|
return XRSettings.enabled && XRSettings.loadedDeviceName != string.Empty && XRSettings.loadedDeviceName != "None";
|
|
}
|
|
|
|
public bool IsControllersInput()
|
|
{
|
|
return IsVROn() && (OVRInput.GetActiveController() == OVRInput.Controller.Touch || OVRInput.GetActiveController() == OVRInput.Controller.LTouch || OVRInput.GetActiveController() == OVRInput.Controller.RTouch);
|
|
}
|
|
|
|
public void UpdateControllerInput()
|
|
{
|
|
if (!VRControllersManager.Instance)
|
|
{
|
|
return;
|
|
}
|
|
currentController = OVRInput.GetActiveController();
|
|
if (currentController == OVRInput.Controller.LTouch || currentController == OVRInput.Controller.RTouch)
|
|
{
|
|
currentController = OVRInput.Controller.Touch;
|
|
}
|
|
if (prevController == currentController)
|
|
{
|
|
return;
|
|
}
|
|
if (currentController == OVRInput.Controller.Gamepad)
|
|
{
|
|
ChangeUIInputStyle(UIInputStyle.GAZE);
|
|
if (playerWalkStyle == PlayerWalkStyle.POINTER_TELEPORT)
|
|
{
|
|
ChangeWalkStyle(PlayerWalkStyle.FREE);
|
|
}
|
|
VRControllersManager.Instance.ShowHandsQuick(false);
|
|
}
|
|
else if (currentController == OVRInput.Controller.Touch)
|
|
{
|
|
ChangeUIInputStyle(UIInputStyle.POINTER);
|
|
VRControllersManager.Instance.ShowHandsQuick(VRControllersManager.Instance.handsVisible);
|
|
}
|
|
prevController = currentController;
|
|
Debug.Log("UpdateControllerInput: " + OVRInput.GetActiveController());
|
|
}
|
|
|
|
public bool IsPlayerFollowCamera()
|
|
{
|
|
return playerFollowCamera && IsVROn();
|
|
}
|
|
|
|
public bool IsVRReeling()
|
|
{
|
|
return vrReeling && IsControllersInput();
|
|
}
|
|
|
|
public bool IsVRReelingGrip()
|
|
{
|
|
return !vrAutoReelgGrip && IsControllersInput();
|
|
}
|
|
|
|
public bool IsVRHoldRod()
|
|
{
|
|
return vrHoldRod && IsControllersInput();
|
|
}
|
|
|
|
public bool IsVRGroundBait()
|
|
{
|
|
return vrGroundbait && IsControllersInput();
|
|
}
|
|
|
|
public bool IsVRDrilling()
|
|
{
|
|
return vrDrilling && IsControllersInput();
|
|
}
|
|
|
|
public bool IsVRFishingNet()
|
|
{
|
|
return vrFishingNet && IsControllersInput();
|
|
}
|
|
|
|
public bool IsVRDriveBoat()
|
|
{
|
|
return vrDriveBoat && IsControllersInput();
|
|
}
|
|
|
|
public bool IsComfortableDriveBoat()
|
|
{
|
|
return vrComfortableDriveBoat && IsVROn();
|
|
}
|
|
|
|
public void SetPlayerFollowCamera(bool turnOn)
|
|
{
|
|
playerFollowCamera = turnOn;
|
|
}
|
|
|
|
public void SetVRReeling(bool turnOn)
|
|
{
|
|
vrReeling = turnOn;
|
|
}
|
|
|
|
public void SetVRReelingGrip(bool turnOn)
|
|
{
|
|
vrAutoReelgGrip = turnOn;
|
|
}
|
|
|
|
public void SetVRHoldRod(bool turnOn)
|
|
{
|
|
vrHoldRod = turnOn;
|
|
}
|
|
|
|
public void SetVRGroundBait(bool turnOn)
|
|
{
|
|
vrGroundbait = turnOn;
|
|
}
|
|
|
|
public void SetVRDrilling(bool turnOn)
|
|
{
|
|
vrDrilling = turnOn;
|
|
}
|
|
|
|
public void SetVRFishingNet(bool turnOn)
|
|
{
|
|
vrFishingNet = turnOn;
|
|
}
|
|
|
|
public void SetVRDriveBoat(bool turnOn)
|
|
{
|
|
vrDriveBoat = turnOn;
|
|
}
|
|
|
|
public void SetComfortableDriveBoat(bool turnOn)
|
|
{
|
|
vrComfortableDriveBoat = turnOn;
|
|
}
|
|
|
|
public void SetTurnAngle(float newTurnAngle)
|
|
{
|
|
turnAngle = newTurnAngle;
|
|
}
|
|
|
|
public void SetMenuSize(float newSize)
|
|
{
|
|
menuSize = newSize;
|
|
MenuManager.Instance.transform.position = new Vector3(MenuManager.Instance.transform.position.x, MenuManager.Instance.transform.position.y, 0f - menuSize);
|
|
FixTutorialPosition();
|
|
}
|
|
|
|
public void SetHUDSize(float newSize, bool init = false)
|
|
{
|
|
hudSize = newSize;
|
|
if (hudSize < hudSizeMinMax.x || hudSize > hudSizeMinMax.y)
|
|
{
|
|
ResetHUDSize();
|
|
}
|
|
if ((bool)HUDManager.Instance)
|
|
{
|
|
if (init)
|
|
{
|
|
hudSizeStartMultiplier = GetUIResolutionFactor();
|
|
}
|
|
HUDManager.Instance.transform.localScale = Vector3.one * hudSize;
|
|
HUDManager.Instance.transform.localScale *= hudSizeStartMultiplier;
|
|
HUDManager.Instance.fishingCanvas.GetComponent<RectTransform>().localScale = Vector3.one;
|
|
HUDManager.Instance.fishingCanvas.GetComponent<RectTransform>().localScale /= hudSizeStartMultiplier;
|
|
}
|
|
}
|
|
|
|
public void ResetHUDSize()
|
|
{
|
|
hudSize = (hudSizeMinMax.x + hudSizeMinMax.y) * 0.5f;
|
|
}
|
|
|
|
public void SetHUDRotateStyle(HUDRotateStyle newHUDRotateStyle)
|
|
{
|
|
hudRotateStyle = newHUDRotateStyle;
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleCurvedUI()
|
|
{
|
|
SetCurvedUI(!useCurvedUI);
|
|
}
|
|
|
|
public void SetCurvedUI(bool turnOn, bool destroy = false)
|
|
{
|
|
turnOn = false;
|
|
if (!IsVROn())
|
|
{
|
|
turnOn = false;
|
|
}
|
|
useCurvedUI = turnOn;
|
|
if (destroy && EventSystem.current.GetComponent<CurvedUIInputModule>() != null)
|
|
{
|
|
CurvedUIInputModule.ControlMethod = CurvedUIInputModule.CUIControlMethod.MOUSE;
|
|
UnityEngine.Object.DestroyImmediate(EventSystem.current.GetComponent<CurvedUIInputModule>());
|
|
EventSystem.current.GetComponent<RewiredStandaloneInputModule>().enabled = true;
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void GetControllerTypeTest()
|
|
{
|
|
Debug.Log(GetControllerType(true).ToString());
|
|
}
|
|
|
|
public static OVRInput.OpenVRController GetControllerType(bool right)
|
|
{
|
|
if (useOculusSDK)
|
|
{
|
|
return OVRInput.OpenVRController.OculusTouch;
|
|
}
|
|
return OVRInput.openVRControllerDetails[right ? 1 : 0].controllerType;
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleVR()
|
|
{
|
|
if (XRSettings.loadedDeviceName == "None" || XRSettings.loadedDeviceName == string.Empty)
|
|
{
|
|
StartCoroutine(LoadDevice("OpenVR"));
|
|
}
|
|
else if (XRSettings.loadedDeviceName == "OpenVR")
|
|
{
|
|
StartCoroutine(LoadDevice("Oculus"));
|
|
}
|
|
else
|
|
{
|
|
StartCoroutine(LoadDevice("None"));
|
|
}
|
|
}
|
|
|
|
public IEnumerator LoadDevice(string deviceName)
|
|
{
|
|
Debug.LogFormat("XRSettings.loadedDeviceName CURRENT: {0}", XRSettings.loadedDeviceName);
|
|
XRSettings.LoadDeviceByName(deviceName);
|
|
yield return null;
|
|
XRSettings.enabled = true;
|
|
forceVRQuality = true;
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
GlobalSettings.Instance.renderSettings.RefreshSettings();
|
|
}
|
|
useOculusSDK = XRSettings.loadedDeviceName == "Oculus";
|
|
useOculusSDKPublic = useOculusSDK;
|
|
Debug.LogFormat("XRSettings.loadedDeviceName NEW: {0}", XRSettings.loadedDeviceName);
|
|
}
|
|
|
|
public void TurnOnUIController(bool turnOn)
|
|
{
|
|
if (!IsVROn())
|
|
{
|
|
turnOn = false;
|
|
}
|
|
RewiredStandaloneInputModule[] array = UnityEngine.Object.FindObjectsOfType<RewiredStandaloneInputModule>();
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
if ((bool)array[i])
|
|
{
|
|
array[i].gameObject.SetActive(!turnOn);
|
|
}
|
|
}
|
|
uiController.SetActive(turnOn);
|
|
if (!IsVROn())
|
|
{
|
|
return;
|
|
}
|
|
ChangeUIInputStyle(uIInputStyle);
|
|
if ((bool)GameController.Instance && (bool)GameController.Instance.fishingPlayer && (bool)GameController.Instance.fishingPlayer.ufpsCamera)
|
|
{
|
|
if (GameController.Instance.fishingPlayer.underwaterCamera.isTurnedOn)
|
|
{
|
|
GameController.Instance.fishingPlayer.underwaterCamera.gameObject.SetActive(!turnOn);
|
|
}
|
|
else
|
|
{
|
|
GameController.Instance.fishingPlayer.ufpsCamera.gameObject.SetActive(!turnOn);
|
|
GameController.Instance.fishingPlayer.GetComponent<AudioListener>().enabled = !turnOn;
|
|
}
|
|
GameController.Instance.fishingPlayer.ovrPlayerController.gameObject.SetActive(!turnOn);
|
|
if (turnOn && IsPlayerFollowCamera())
|
|
{
|
|
vrPlayer.transform.localEulerAngles = new Vector3(vrPlayer.transform.localEulerAngles.x, 0f - GameController.Instance.fishingPlayer.ufpsCamera.transform.localEulerAngles.y, vrPlayer.transform.localEulerAngles.z);
|
|
}
|
|
else
|
|
{
|
|
vrPlayer.transform.localEulerAngles = new Vector3(vrPlayer.transform.localEulerAngles.x, 0f, vrPlayer.transform.localEulerAngles.z);
|
|
}
|
|
}
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
GlobalSettings.Instance.renderSettings.RefreshVRShadows();
|
|
}
|
|
}
|
|
|
|
public void ChangeWalkStyle(PlayerWalkStyle newWalkStyle)
|
|
{
|
|
if (!Instance.IsControllersInput() && newWalkStyle == PlayerWalkStyle.POINTER_TELEPORT)
|
|
{
|
|
newWalkStyle = PlayerWalkStyle.GAZE_TELEPORT;
|
|
}
|
|
playerWalkStyle = newWalkStyle;
|
|
if ((bool)GameController.Instance && (bool)GameController.Instance.fishingPlayer)
|
|
{
|
|
GameController.Instance.fishingPlayer.GetComponentInChildren<VRTeleport>().RefreshTeleportStyle();
|
|
}
|
|
}
|
|
|
|
public void ChangeRotateStyle(PlayerRotateStyle newRotateStyle)
|
|
{
|
|
playerRotateStyle = newRotateStyle;
|
|
}
|
|
|
|
public void ChangeTeleportStyle(TeleportStyle newTeleportStyle)
|
|
{
|
|
teleportStyle = newTeleportStyle;
|
|
}
|
|
|
|
public void ChangeEyeTextureResolutionScale(float newScale)
|
|
{
|
|
currentEyeResolutionScale = newScale;
|
|
}
|
|
|
|
public void RefreshEyeTextureResolutionScale(bool isMenu)
|
|
{
|
|
XRSettings.eyeTextureResolutionScale = ((!isMenu) ? currentEyeResolutionScale : 1.3f);
|
|
}
|
|
|
|
public void ChangeCameraHeight(float newHeight)
|
|
{
|
|
cameraHeight = newHeight;
|
|
if ((bool)GameController.Instance && (bool)GameController.Instance.fishingPlayer)
|
|
{
|
|
GameController.Instance.fishingPlayer.ChangeVRCameraHeight(cameraHeight);
|
|
}
|
|
uiController.transform.localPosition = new Vector3(uiController.transform.localPosition.x, cameraHeight, uiController.transform.localPosition.z);
|
|
}
|
|
|
|
public void ShowPlayerFPSCounter(bool show)
|
|
{
|
|
showAfpsCounter = show;
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.fishingPlayer.afpsCounter.gameObject.SetActive(show);
|
|
GameController.Instance.fishingPlayer.afpsCounter.Shadow = true;
|
|
}
|
|
}
|
|
|
|
public static float GetUIResolutionFactor()
|
|
{
|
|
return 600f / (float)Screen.height;
|
|
}
|
|
|
|
[Button]
|
|
public void ShowInputInfo()
|
|
{
|
|
Debug.Log(string.Concat("ShowInputInfo: IsControllerConnected: ", OVRInput.IsControllerConnected(OVRInput.Controller.Touch), " GetLocalControllerPosition: ", OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch), " GetLocalControllerRotation: ", OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch).eulerAngles, " GetLocalControllerVelocity: ", OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTouch), " GetLocalControllerAcceleration: ", OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.RTouch), " GetConnectedControllers: ", OVRInput.GetConnectedControllers(), " GetActiveController: ", OVRInput.GetActiveController()));
|
|
Debug.Log("Input.GetJoystickNames: " + Input.GetJoystickNames().ToStringFull());
|
|
}
|
|
|
|
[Button]
|
|
public void ShowXRInfo()
|
|
{
|
|
Debug.LogFormat("XR Settings enabled {0} loadedDeviceName {1} renderViewportScale {2} supportedDevices {3} eyeTextureHeight {4} eyeTextureWidth {5} ", XRSettings.enabled, XRSettings.loadedDeviceName, XRSettings.renderViewportScale, XRSettings.supportedDevices.ToStringFull(), XRSettings.eyeTextureHeight, XRSettings.eyeTextureWidth);
|
|
Debug.Log("XRDevice: XRDevice.model " + XRDevice.model);
|
|
Debug.Log("XR Device ");
|
|
}
|
|
|
|
[Button]
|
|
public void Recenter()
|
|
{
|
|
InputTracking.Recenter();
|
|
Debug.Log("InputTracking.Recenter");
|
|
}
|
|
|
|
[Button]
|
|
public void OvrRecenter()
|
|
{
|
|
OVRManager.display.RecenterPose();
|
|
Debug.Log("OVRManager.display.RecenterPose");
|
|
}
|
|
|
|
[Button]
|
|
public void WriteValveIndexInformation()
|
|
{
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleRenderViewportScale()
|
|
{
|
|
if (XRSettings.renderViewportScale == 1f)
|
|
{
|
|
XRSettings.renderViewportScale = 0.9f;
|
|
}
|
|
else if (XRSettings.renderViewportScale == 0.9f)
|
|
{
|
|
XRSettings.renderViewportScale = 0.93f;
|
|
}
|
|
else if (XRSettings.renderViewportScale == 0.93f)
|
|
{
|
|
XRSettings.renderViewportScale = 0.96f;
|
|
}
|
|
else
|
|
{
|
|
XRSettings.renderViewportScale = 1f;
|
|
}
|
|
Debug.Log("XRSettings.renderViewportScale: " + XRSettings.renderViewportScale);
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleEyeTextureResolutionScale()
|
|
{
|
|
if (XRSettings.eyeTextureResolutionScale == 1f)
|
|
{
|
|
XRSettings.eyeTextureResolutionScale = 0.8f;
|
|
}
|
|
else if (XRSettings.eyeTextureResolutionScale == 0.8f)
|
|
{
|
|
XRSettings.eyeTextureResolutionScale = 0.6f;
|
|
}
|
|
else
|
|
{
|
|
XRSettings.eyeTextureResolutionScale = 1f;
|
|
}
|
|
Debug.Log("XRSettings.renderScale: " + XRSettings.eyeTextureResolutionScale);
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleShadows()
|
|
{
|
|
if (tempShadowDistance < 0f)
|
|
{
|
|
tempShadowDistance = QualitySettings.shadowDistance;
|
|
}
|
|
if (QualitySettings.shadowDistance == 0f)
|
|
{
|
|
QualitySettings.shadowDistance = tempShadowDistance;
|
|
}
|
|
else if (QualitySettings.shadowDistance == tempShadowDistance)
|
|
{
|
|
QualitySettings.shadowDistance = tempShadowDistance * 2f;
|
|
}
|
|
else
|
|
{
|
|
QualitySettings.shadowDistance = 0f;
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleShadowsQuality()
|
|
{
|
|
if (QualitySettings.shadowResolution == ShadowResolution.Low)
|
|
{
|
|
QualitySettings.shadowResolution = ShadowResolution.Medium;
|
|
}
|
|
else if (QualitySettings.shadowResolution == ShadowResolution.Medium)
|
|
{
|
|
QualitySettings.shadowResolution = ShadowResolution.High;
|
|
}
|
|
else if (QualitySettings.shadowResolution == ShadowResolution.High)
|
|
{
|
|
QualitySettings.shadowResolution = ShadowResolution.VeryHigh;
|
|
}
|
|
else
|
|
{
|
|
QualitySettings.shadowResolution = ShadowResolution.Low;
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleLOD()
|
|
{
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleFishDistanceBehavior()
|
|
{
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
if (GlobalSettings.Instance.renderSettings.GetQualityDefinition().fishDistanceBehaviorMultiplier == 0.5f)
|
|
{
|
|
GlobalSettings.Instance.renderSettings.GetQualityDefinition().fishDistanceBehaviorMultiplier = 0.6f;
|
|
}
|
|
else if (GlobalSettings.Instance.renderSettings.GetQualityDefinition().fishDistanceBehaviorMultiplier == 0.6f)
|
|
{
|
|
GlobalSettings.Instance.renderSettings.GetQualityDefinition().fishDistanceBehaviorMultiplier = 0.7f;
|
|
}
|
|
else
|
|
{
|
|
GlobalSettings.Instance.renderSettings.GetQualityDefinition().fishDistanceBehaviorMultiplier = 0.5f;
|
|
}
|
|
Debug.Log("fishDistanceBehaviorMultiplier: " + GlobalSettings.Instance.renderSettings.GetQualityDefinition().fishDistanceBehaviorMultiplier);
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleAmplifyColor()
|
|
{
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
AmplifyColorEffect component = GameController.Instance.fishingPlayer.ufpsWeaponCamera.GetComponent<AmplifyColorEffect>();
|
|
component.enabled = !component.enabled;
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleTonemapping()
|
|
{
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
DeluxeTonemapper component = GameController.Instance.fishingPlayer.ufpsWeaponCamera.GetComponent<DeluxeTonemapper>();
|
|
component.enabled = !component.enabled;
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleGlobalFog()
|
|
{
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.fishingPlayer.volumetricFog.enabled = !GameController.Instance.fishingPlayer.volumetricFog.enabled;
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleStrongFog()
|
|
{
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GlobalFog component = GameController.Instance.fishingPlayer.ufpsCamera.GetComponent<GlobalFog>();
|
|
component.heightDensity = ((component.heightDensity != 0.1f) ? 0.1f : 0.01f);
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleDOF()
|
|
{
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.fishingPlayer.depthOfField.enabled = !GameController.Instance.fishingPlayer.depthOfField.enabled;
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleLODMax()
|
|
{
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
QualitySettings.maximumLODLevel = ((QualitySettings.maximumLODLevel == 0) ? 1 : 0);
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ToggleLODBias()
|
|
{
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
if (QualitySettings.lodBias == 0.4f)
|
|
{
|
|
QualitySettings.lodBias = 0.6f;
|
|
}
|
|
else if (QualitySettings.lodBias == 0.6f)
|
|
{
|
|
QualitySettings.lodBias = 0.8f;
|
|
}
|
|
else if (QualitySettings.lodBias == 0.8f)
|
|
{
|
|
QualitySettings.lodBias = 1f;
|
|
}
|
|
else
|
|
{
|
|
QualitySettings.lodBias = 0.4f;
|
|
}
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ChangeSupportedDevices()
|
|
{
|
|
}
|
|
|
|
public void ShowKeyboard(InputField inputField, Vector3 keyboardPosition)
|
|
{
|
|
keyboardManager.gameObject.SetActive(true);
|
|
keyboardManager.ChangeInputField(inputField);
|
|
if ((bool)GameController.Instance && (!MenuManager.Instance || !MenuManager.Instance.gameObject.activeSelf))
|
|
{
|
|
Vector3 position = GameController.Instance.fishingPlayer.ufpsCamera.transform.position;
|
|
position += GameController.Instance.fishingPlayer.GetForwardVector() * 1f;
|
|
keyboardManager.transform.position = position;
|
|
keyboardManager.transform.eulerAngles = new Vector3(0f, GameController.Instance.fishingPlayer.ufpsCamera.transform.eulerAngles.y, 0f);
|
|
keyboardManager.transform.localScale = Vector3.one * 0.003f;
|
|
keyboardManager.GetComponent<Canvas>().worldCamera = GameController.Instance.fishingPlayer.ufpsCameraCamera;
|
|
GameController.Instance.fishingPlayer.vrPlayertUIInput.TurnOnUIController(true);
|
|
}
|
|
else
|
|
{
|
|
keyboardManager.transform.position = keyboardPosition;
|
|
keyboardManager.transform.rotation = Quaternion.identity;
|
|
keyboardManager.transform.localScale = Vector3.one * 0.009f;
|
|
keyboardManager.GetComponent<Canvas>().worldCamera = eyeCenterTransform.GetComponent<Camera>();
|
|
}
|
|
}
|
|
|
|
public void HideKeyboard()
|
|
{
|
|
keyboardManager.ChangeInputField(null);
|
|
keyboardManager.gameObject.SetActive(false);
|
|
}
|
|
|
|
public void ShowMenuEnviro(bool show)
|
|
{
|
|
menuEnviroParent.SetActive(show);
|
|
}
|
|
|
|
public void OculusDashboardShown(bool show)
|
|
{
|
|
if (!useOculusSDK)
|
|
{
|
|
return;
|
|
}
|
|
isOculusDashboardOn = show;
|
|
Utilities.LogError("OculusDashboardShown: " + show, "teal");
|
|
if ((bool)HUDManager.Instance && HUDManager.Instance.currentHudState == HUDManager.HUDState.GAME)
|
|
{
|
|
Time.timeScale = ((!show) ? 1f : 0f);
|
|
}
|
|
if ((bool)SingletonMonoBehaviour<AudioController>.Instance)
|
|
{
|
|
AudioController.SetGlobalVolume((!show) ? 1f : 0.01f);
|
|
}
|
|
if ((bool)VRControllersManager.Instance)
|
|
{
|
|
VRControllersManager.Instance.handRight.gameObject.SetActive(!show);
|
|
VRControllersManager.Instance.handLeft.gameObject.SetActive(!show);
|
|
}
|
|
Utilities.SetLayerRecursively(gazeInputParent, (!show) ? "UI" : "TransparentFX");
|
|
Utilities.SetLayerRecursively(pointerInputParent, (!show) ? "UI" : "TransparentFX");
|
|
if (!GameController.Instance || !GameController.Instance.fishingPlayer)
|
|
{
|
|
return;
|
|
}
|
|
if (show)
|
|
{
|
|
isWeaponLayerOn = Utilities.IsLayerInLayerMask(GameController.Instance.fishingPlayer.ufpsCameraCamera.cullingMask, "Weapon");
|
|
if (isWeaponLayerOn)
|
|
{
|
|
GameController.Instance.fishingPlayer.ufpsCameraCamera.cullingMask = Utilities.RemoveFromLayerMask(GameController.Instance.fishingPlayer.ufpsCameraCamera.cullingMask, "Weapon");
|
|
}
|
|
}
|
|
else if (isWeaponLayerOn)
|
|
{
|
|
GameController.Instance.fishingPlayer.ufpsCameraCamera.cullingMask = Utilities.AddToLayerMask(GameController.Instance.fishingPlayer.ufpsCameraCamera.cullingMask, "Weapon");
|
|
}
|
|
}
|
|
|
|
public void OnHeadsetMount()
|
|
{
|
|
if (useOculusSDK && !isOculusDashboardOn)
|
|
{
|
|
Utilities.LogError("OnHeadsetMount");
|
|
if ((bool)HUDManager.Instance && HUDManager.Instance.currentHudState == HUDManager.HUDState.GAME)
|
|
{
|
|
Time.timeScale = 1f;
|
|
}
|
|
if ((bool)SingletonMonoBehaviour<AudioController>.Instance)
|
|
{
|
|
AudioController.SetGlobalVolume(1f);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnHeadsetUnmount()
|
|
{
|
|
if (useOculusSDK)
|
|
{
|
|
Utilities.LogError("OnHeadsetUnmount");
|
|
if ((bool)HUDManager.Instance && HUDManager.Instance.currentHudState == HUDManager.HUDState.GAME)
|
|
{
|
|
Time.timeScale = 0f;
|
|
}
|
|
if ((bool)SingletonMonoBehaviour<AudioController>.Instance)
|
|
{
|
|
AudioController.SetGlobalVolume(0.01f);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
string currentProfilePrefix = GlobalSettings.Instance.saveManager.GetCurrentProfilePrefix();
|
|
using (ES2Writer eS2Writer = ES2Writer.Create(currentProfilePrefix))
|
|
{
|
|
eS2Writer.Write((int)uIInputStyle, "VR_UIInputStyle");
|
|
eS2Writer.Write((int)playerWalkStyle, "VR_WalkStyle");
|
|
eS2Writer.Write((int)playerRotateStyle, "VR_RotateStyle");
|
|
eS2Writer.Write((int)teleportStyle, "VR_TeleportStyle");
|
|
eS2Writer.Write((int)hudRotateStyle, "VR_HUDRotateStyle");
|
|
eS2Writer.Write(playerFollowCamera, "VR_PlayerFollowCamera");
|
|
eS2Writer.Write(currentEyeResolutionScale, "VR_EyeResolutionScale");
|
|
eS2Writer.Write(cameraHeight, "VR_CameraHeight");
|
|
eS2Writer.Write(turnAngle, "VR_TurnAngle");
|
|
eS2Writer.Write(menuSize, "VR_MenuSize");
|
|
eS2Writer.Write(hudSize, "VR_HUDSize");
|
|
eS2Writer.Write(useCurvedUI, "VR_UseCurvedUI");
|
|
eS2Writer.Write(VRControllersManager.Instance.IsLeftHanded(), "VR_LeftHanded");
|
|
eS2Writer.Write(VRControllersManager.Instance.handsVisible, "VR_ShowControllers");
|
|
eS2Writer.Write(vrReeling, "VR_GameplayReeling");
|
|
eS2Writer.Write(vrAutoReelgGrip, "VR_GameplayReelingGrip");
|
|
eS2Writer.Write(vrGroundbait, "VR_GameplayGroundbait");
|
|
eS2Writer.Write(vrHoldRod, "VR_GameplayHoldRod");
|
|
eS2Writer.Write(vrDrilling, "VR_GameplayDrilling");
|
|
eS2Writer.Write(vrFishingNet, "VR_GameplayFishingNet");
|
|
eS2Writer.Write(vrDriveBoat, "VR_GameplayDriveBoat");
|
|
eS2Writer.Write(vrComfortableDriveBoat, "VR_GameplayComfortableDriveBoat");
|
|
eS2Writer.Write(VRControllersManager.Instance.handReelSpeedMultiplier, "handReelSpeedMultiplier");
|
|
eS2Writer.Write(VRControllersManager.Instance.handReelNoFishSpeedMultiplier, "handReelNoFishSpeedMultiplier");
|
|
eS2Writer.Save();
|
|
Debug.Log("Save VRManager");
|
|
}
|
|
}
|
|
|
|
public void Load()
|
|
{
|
|
string currentProfilePrefix = GlobalSettings.Instance.saveManager.GetCurrentProfilePrefix();
|
|
int gameVersion = GlobalSettings.Instance.gameVersion;
|
|
using (ES2Reader eS2Reader = ES2Reader.Create(currentProfilePrefix))
|
|
{
|
|
uIInputStyle = (UIInputStyle)SaveManager.Read(eS2Reader, "VR_UIInputStyle", 1);
|
|
ChangeUIInputStyle(uIInputStyle);
|
|
playerWalkStyle = (PlayerWalkStyle)SaveManager.Read(eS2Reader, "VR_WalkStyle", 0);
|
|
playerRotateStyle = (PlayerRotateStyle)SaveManager.Read(eS2Reader, "VR_RotateStyle", 1);
|
|
teleportStyle = (TeleportStyle)SaveManager.Read(eS2Reader, "VR_TeleportStyle", 1);
|
|
hudRotateStyle = (HUDRotateStyle)SaveManager.Read(eS2Reader, "VR_HUDRotateStyle", 2);
|
|
playerFollowCamera = SaveManager.Read(eS2Reader, "VR_PlayerFollowCamera", true);
|
|
currentEyeResolutionScale = SaveManager.Read(eS2Reader, "VR_EyeResolutionScale", 1f);
|
|
cameraHeight = SaveManager.Read(eS2Reader, "VR_CameraHeight", 0f);
|
|
turnAngle = SaveManager.Read(eS2Reader, "VR_TurnAngle", 30f);
|
|
menuSize = SaveManager.Read(eS2Reader, "VR_MenuSize", 0f);
|
|
hudSize = SaveManager.Read(eS2Reader, "VR_HUDSize", (hudSizeMinMax.x + hudSizeMinMax.y) * 0.5f);
|
|
useCurvedUI = false;
|
|
if (eS2Reader.TagExists("VR_LeftHanded"))
|
|
{
|
|
VRControllersManager.Instance.SetLeftHanded(SaveManager.Read(eS2Reader, "VR_LeftHanded", false));
|
|
Instance.pointerInputParent.GetComponent<HandedInputSelector>().SetActiveController(VRControllersManager.Instance.IsLeftHanded() ? OVRInput.Controller.LTouch : OVRInput.Controller.RTouch);
|
|
}
|
|
VRControllersManager.Instance.handsVisible = SaveManager.Read(eS2Reader, "VR_ShowControllers", true);
|
|
VRControllersManager.Instance.ShowHands(VRControllersManager.Instance.handsVisible);
|
|
VRControllersManager.Instance.handReelSpeedMultiplier = SaveManager.Read(eS2Reader, "handReelSpeedMultiplier", 1.5f);
|
|
VRControllersManager.Instance.handReelNoFishSpeedMultiplier = SaveManager.Read(eS2Reader, "handReelNoFishSpeedMultiplier", 1f);
|
|
ChangeCameraHeight(cameraHeight);
|
|
SetMenuSize(menuSize);
|
|
vrReeling = SaveManager.Read(eS2Reader, "VR_GameplayReeling", true);
|
|
vrAutoReelgGrip = SaveManager.Read(eS2Reader, "VR_GameplayReelingGrip", false);
|
|
vrGroundbait = SaveManager.Read(eS2Reader, "VR_GameplayGroundbait", true);
|
|
vrHoldRod = SaveManager.Read(eS2Reader, "VR_GameplayHoldRod", true);
|
|
vrHoldRod = true;
|
|
vrDrilling = SaveManager.Read(eS2Reader, "VR_GameplayDrilling", true);
|
|
vrFishingNet = SaveManager.Read(eS2Reader, "VR_GameplayFishingNet", true);
|
|
vrDriveBoat = SaveManager.Read(eS2Reader, "VR_GameplayDriveBoat", true);
|
|
vrComfortableDriveBoat = SaveManager.Read(eS2Reader, "VR_GameplayComfortableDriveBoat", true);
|
|
}
|
|
SetCurvedUI(useCurvedUI);
|
|
if (GetControllerType(true) == OVRInput.OpenVRController.WindowsMRController)
|
|
{
|
|
gazeInputParent.GetComponentInChildren<OVRInputModule>(true).rightStickDeadZone = 0.35f;
|
|
pointerInputParent.GetComponentInChildren<OVRInputModule>(true).rightStickDeadZone = 0.35f;
|
|
VRInputManager.axisDeadzone = 0.25f;
|
|
}
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
uIInputStyle = UIInputStyle.POINTER;
|
|
playerWalkStyle = PlayerWalkStyle.FREE;
|
|
playerRotateStyle = PlayerRotateStyle.STEP;
|
|
teleportStyle = TeleportStyle.FADE;
|
|
hudRotateStyle = HUDRotateStyle.STEP;
|
|
playerFollowCamera = true;
|
|
currentEyeResolutionScale = 1f;
|
|
cameraHeight = 0f;
|
|
turnAngle = 30f;
|
|
menuSize = 0f;
|
|
SetMenuSize(menuSize);
|
|
ResetHUDSize();
|
|
useCurvedUI = false;
|
|
if (GlobalSettings.Instance.currentPlatform == GlobalSettings.Platform.ARCADE)
|
|
{
|
|
VRControllersManager.Instance.handsVisible = true;
|
|
VRControllersManager.Instance.SetLeftHanded(false);
|
|
}
|
|
VRControllersManager.Instance.ShowHands(true);
|
|
VRControllersManager.Instance.handReelSpeedMultiplier = 1.5f;
|
|
VRControllersManager.Instance.handReelNoFishSpeedMultiplier = 1f;
|
|
vrReeling = true;
|
|
vrAutoReelgGrip = false;
|
|
vrGroundbait = true;
|
|
vrHoldRod = true;
|
|
vrDrilling = true;
|
|
vrFishingNet = true;
|
|
vrDriveBoat = true;
|
|
vrComfortableDriveBoat = true;
|
|
}
|
|
}
|