03-30-2020 04:25 PM
04-17-2020 08:49 AM
04-17-2020 10:59 AM
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GamePause : MonoBehaviour
{
[SerializeField] private GameObject pauseObject;
private AudioSource audioSource; // assuming music is attached to this GO
private void OnEnable()
{
OVRManager.HMDUnmounted += PauseGame;
OVRManager.HMDMounted += UnPauseGame;
OVRManager.VrFocusLost += PauseGame;
OVRManager.VrFocusAcquired += UnPauseGame;
audioSource = GetComponent();
}
private void OnDisable()
{
OVRManager.HMDUnmounted -= PauseGame;
OVRManager.HMDMounted -= UnPauseGame;
OVRManager.VrFocusLost -= PauseGame;
OVRManager.VrFocusAcquired -= UnPauseGame;
}
private void PauseGame()
{
if (pauseObject != null)
pauseObject.SetActive(true);
Time.timeScale = 0.0f;
if (audioSource != null)
audioSource.Pause();
}
private void UnPauseGame()
{
if (OVRManager.hasVrFocus)
{
if (pauseObject != null)
pauseObject.SetActive(false);
Time.timeScale = 1.0f;
if (audioSource != null)
audioSource.UnPause();
}
}
}
05-13-2020 02:40 PM
OjosLindos said:
I just received a support ticket response from Oculus Developer Support, shown below. I'll try this out today. Let's keep our fingers crossed.
Have you referred to the Input Focus sample in the Oculus integration for an example of typical handling for the loss of input focus in an application? The sample can be found in the SampleFramework folder.
Additionally, an example script that you may want to try is the following:using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GamePause : MonoBehaviour
{
[SerializeField] private GameObject pauseObject;
private AudioSource audioSource; // assuming music is attached to this GO
private void OnEnable()
{
OVRManager.HMDUnmounted += PauseGame;
OVRManager.HMDMounted += UnPauseGame;
OVRManager.VrFocusLost += PauseGame;
OVRManager.VrFocusAcquired += UnPauseGame;
audioSource = GetComponent();
}
private void OnDisable()
{
OVRManager.HMDUnmounted -= PauseGame;
OVRManager.HMDMounted -= UnPauseGame;
OVRManager.VrFocusLost -= PauseGame;
OVRManager.VrFocusAcquired -= UnPauseGame;
}
private void PauseGame()
{
if (pauseObject != null)
pauseObject.SetActive(true);
Time.timeScale = 0.0f;
if (audioSource != null)
audioSource.Pause();
}
private void UnPauseGame()
{
if (OVRManager.hasVrFocus)
{
if (pauseObject != null)
pauseObject.SetActive(false);
Time.timeScale = 1.0f;
if (audioSource != null)
audioSource.UnPause();
}
}
}
05-14-2020 09:48 AM