I would like to know how to open URL on button click in Gear VR App. Samsung Internet App in Oculus Store can be used in this scenario. Just like in 2D Non-VR Android Application, URL is automatically opened in Chrome or Firefox based on default browser. But in Gear VR app when I call
Application.OpenURL("http://www.google.co.uk");
the app freezes.
If this is not possible at all, then is there a way to show intractable Web-View in 3D space?
Any kind of help will be appreciated.
I had found the solution from this post on Oculus forum.
Here is the working code:
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.google.co.uk");
}
}
m_UserPresent = isUserPresent;
#endif
}
#endregion
}
It will wait until the user has removed the headset before opening the app to avoid the jarring visuals of the app freezing when you try to open the URL. If the player takes the headset off and puts it back on they will be returned to where they were in the game.
Hope this helps late users :)
Courtesy: Glitchers Games
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With