using UnityEngine; public class VRController : MonoBehaviour { public GameObject modelParent; public GameObject infoParent; public GameObject gameplayTransformsParent; [Header("Buttons")] public VRControllerButton startButton; public VRControllerButton oneButton; public VRControllerButton twoButton; public VRControllerButton thumbstickButton; public VRControllerButton indexTrigger; public VRControllerButton handTrigger; public VRControllerButton upButton; public VRControllerButton downButton; public VRControllerButton leftButton; public VRControllerButton rightButton; public bool isTouchController; [Header("Gameplay transforms")] public Transform pointerTeleportTransform; public Transform pointerUITransform; public Transform throwObjectTransform; public Transform reelCatchTransform; public Transform flyHandTransform; public Transform rodHoldTransform; public Transform fishingNetHoldTransform; public Transform boatWheelTransform; public Transform drillerHoldTransform; public Transform drillerRotateTransform; private void Start() { } public void UpdateInfo(OVRInput.Button button, string infoText) { VRControllerButton vRControllerButton = FindButton(button); if (vRControllerButton == null) { Debug.LogError("VRController button not found: " + button); return; } if (infoText == string.Empty) { vRControllerButton.gameObject.SetActive(false); return; } if (isTouchController) { switch (button) { case OVRInput.Button.Up: infoText = "(" + Utilities.GetTranslation("HUD_CONTROLS/UP") + ") " + infoText; break; case OVRInput.Button.Down: infoText = "(" + Utilities.GetTranslation("HUD_CONTROLS/DOWN") + ") " + infoText; break; case OVRInput.Button.Left: infoText = "(" + Utilities.GetTranslation("HUD_CONTROLS/LEFT") + ") " + infoText; break; case OVRInput.Button.Right: infoText = "(" + Utilities.GetTranslation("HUD_CONTROLS/RIGHT") + ") " + infoText; break; } } vRControllerButton.UpdateInfoText(infoText); } public VRControllerButton FindButton(OVRInput.Button button) { switch (button) { case OVRInput.Button.Start: return startButton; case OVRInput.Button.One: return oneButton; case OVRInput.Button.Two: return twoButton; case OVRInput.Button.PrimaryThumbstick: return thumbstickButton; case OVRInput.Button.SecondaryThumbstick: return thumbstickButton; case OVRInput.Button.PrimaryIndexTrigger: return indexTrigger; case OVRInput.Button.SecondaryIndexTrigger: return indexTrigger; case OVRInput.Button.PrimaryHandTrigger: return handTrigger; case OVRInput.Button.SecondaryHandTrigger: return handTrigger; case OVRInput.Button.Up: return upButton; case OVRInput.Button.Down: return downButton; case OVRInput.Button.Left: return leftButton; case OVRInput.Button.Right: return rightButton; default: return null; } } public void HideAllInfo() { if ((bool)startButton) { startButton.gameObject.SetActive(false); } if ((bool)oneButton) { oneButton.gameObject.SetActive(false); } if ((bool)twoButton) { twoButton.gameObject.SetActive(false); } if ((bool)thumbstickButton) { thumbstickButton.gameObject.SetActive(false); } if ((bool)indexTrigger) { indexTrigger.gameObject.SetActive(false); } if ((bool)handTrigger) { handTrigger.gameObject.SetActive(false); } if ((bool)upButton) { upButton.gameObject.SetActive(false); } if ((bool)downButton) { downButton.gameObject.SetActive(false); } if ((bool)leftButton) { leftButton.gameObject.SetActive(false); } if ((bool)rightButton) { rightButton.gameObject.SetActive(false); } } }