如何在虚拟现实 (GearVR) 应用程序中打开 URL

How to open URL in Virtual Reality (GearVR) App

我想知道如何在 Gear VR App 中点击按钮打开 URL。 Oculus Store 中的 Samsung Internet App 可以在这种情况下使用。就像在 2D 非 VR Android 应用程序中一样,URL 会根据默认浏览器在 Chrome 或 Firefox 中自动打开。但是在 Gear VR 应用程序中,当我调用

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

应用冻结。

如果这根本不可能,那么有没有办法在 3D 中显示棘手的 Web 视图 space?

我们将不胜感激。

我在 Oculus 论坛上 this post 找到了解决方案。

这是工作代码:

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.


希望这对迟到的用户有帮助:)

礼貌:Glitchers Games