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

Uma*_*r M 5 c# android unity-game-engine gear-vr

我想知道如何在Gear VR App中点击按钮打开URL.Oculus Store中的Samsung Internet App可用于此场景.就像2D非VR Android应用程序一样,URL会根据默认浏览器在Chrome或Firefox中自动打开.但是当我打电话时,在Gear VR app中

Application.OpenURL("http://www.google.co.uk");
Run Code Online (Sandbox Code Playgroud)

该应用程序冻结.

如果根本不可能,那么有没有办法在3D空间中显示难以处理的Web视图?

任何形式的帮助将不胜感激.

Uma*_*r M 1

我从 Oculus 论坛上的这篇文章中找到了解决方案。

这是工作代码:

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
}
Run Code Online (Sandbox Code Playgroud)

它将等到用户摘下耳机后再打开应用程序,以避免在您尝试打开 URL 时应用程序冻结的不和谐视觉效果。如果玩家摘下耳机并重新戴上,他们将返回到游戏中的位置。


希望这对后期用户有所帮助:)

礼貌:Glitchers Games