How to open URL in Virtual Reality (GearVR) app

I would like to know how to open the url when a button is clicked in the Gear VR app. The Samsung Internet App in the Oculus Store can be used in this scenario. Just like in a non-VR 2D application, the URL will automatically open in Chrome or Firefox based on the default browser. But in the Gear VR app when I call

Application.OpenURL("http://www.google.co.uk"); 

The application freezes.

If this is not possible at all, is there a way to show insoluble web browsing in 3D space?

Any help would be appreciated.

+5
source share
1 answer

I found a solution from this post on the 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 } 

Wait for the user to remove the headset before opening the application to avoid the harsh visual effects of the application when you try to open the URL. If the player turned off the headset and turned it on again they will be returned to where they were in the game.


Hope this helps later users :)

Courtesy: Glitter Games

+1
source

Source: https://habr.com/ru/post/1257392/


All Articles