Skip to content

Instantly share code, notes, and snippets.

@glitchersgames
Last active December 24, 2019 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glitchersgames/557bc2dce118221b5e3734c2e900fac9 to your computer and use it in GitHub Desktop.
Save glitchersgames/557bc2dce118221b5e3734c2e900fac9 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OpenWebsiteOnHeadsetRemove : MonoBehaviour
{
#region Serialized
public OVRManager m_OVRManager;
#endregion
#region Variables
private bool m_UserPresent = true;
private bool m_HasOpenedURL = false;
#endregion
#region Lifecycle
private void Update () {
#if UNITY_ANDROID
bool isUserPresent = m_OVRManager.isUserPresent;
if( m_UserPresent != isUserPresent )
{
if( isUserPresent == false && m_HasOpenedURL == false && Application.isEditor == false )
{
m_HasOpenedURL = true;
Application.OpenURL("http://www.glitchers.com");
}
}
m_UserPresent = isUserPresent;
#endif
}
#endregion
}
@glitchersgames
Copy link
Author

Calling Application.OpenURL in OnApplicationQuit works well. I've had different degrees of success with each.

@MuhammadHassanQ
Copy link

MuhammadHassanQ commented Dec 24, 2019

Hey glitchersgames, I am trying to open a url from gear vr app, but clicking on the button that is registered to application.openurl does nothing when doing from the Gear VR headset. But it works perfectly fine if I turn on the VR developer settings from the mobile and run the app without inserting it into the headset. Do you know what else can I do? It doesn't freeze the app but does nothing instead when done with the headset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment