我在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
}
它會等到用戶打開 應用,以避免應用程序凍結不和諧的視覺效果之前取出耳機,當您嘗試 打開URL。如果玩家關閉耳機並將其放回 ,他們將返回到他們在遊戲中的位置。
希望這有助於後期用戶:)
禮貌:Glitchers Games