有谁知道如何在最新的 google vr sdk 中禁用 Divider、设置和后退按钮以实现统一?
我尝试将 NativeUILayerSupported 设置为 false 并在旧版 DrawUILayer 中添加一个返回值,但它仍然显示。
看来,旧的做法现在已完全弃用。
对于 iOS,请尝试更改以下内容:在 Unity 中,Plugins/iOS/CardboardAppController.mm ->
@implementation CardboardAppController
- (UnityView *)createUnityView {
UnityRegisterViewControllerListener(self);
UnityRegisterAudioPlugin(UnityGetAudioEffectDefinitions);
UnityView* unity_view = [super createUnityView];
//createUiLayer(self, (UIView *)unity_view); <- comment this line
return unity_view;
}
@PerryHart 我在使用 Google VR SDK 时遇到了同样的问题。问题是在最新版本的 GVR SDK 中没有禁用按钮和其他 UI 层的接口。但是 Google VR SDK 0.8 和低于 0.8 提供了接口,您可以通过它轻松完成。
从代码中禁用这些层非常复杂,我花了 2 周时间通过 GVR 1.xx 版本中的代码来完成这些工作。
您可以从此处下载 Google VR SDK 0.8.1。
我正在使用适用于 Android 的 Google VR SDK 而不是 Google VR Unity,这是我的解决方案:
在android中,隐藏两个按钮的弃用方法是
// called by VrView
setSettingsButtonEnabled(false);
既然现在不能用了,那就自己找这两个按钮隐藏吧:
findViewById(R.id.ui_back_button).setVisibility(GONE);
findViewById(R.id.ui_settings_button).setVisibility(GONE);
尝试禁用UI 层设置下Cardboard脚本上的设置为 false。
从界面而不是代码中执行此操作。
我的场景:
什么对我有用(使用 gvr 1.3):
进入 AndroidDevice.cs 脚本并注释以下标有 ### 的行
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#if UNITY_ANDROID && !UNITY_HAS_GOOGLEVR
using UnityEngine;
/// @cond
namespace Gvr.Internal {
public class AndroidDevice : GvrDevice {
// private const string ActivityListenerClass = ######
// "com.google.vr.platform.unity.UnityVrActivityListener"; ######
private static AndroidJavaObject activityListener;
public override void Init() {
SetApplicationState();
base.Init();
ConnectToActivity();
}
protected override void ConnectToActivity() {
base.ConnectToActivity();
if (androidActivity != null && activityListener == null) {
// activityListener = Create(ActivityListenerClass); #####
}
}
public override void SetVRModeEnabled(bool enabled) {
CallObjectMethod(activityListener, "setVRModeEnabled", enabled);
}
public override void ShowSettingsDialog() {
// CallObjectMethod(activityListener, "launchConfigureActivity"); #####
}
public override void OnPause(bool pause) {
base.OnPause(pause);
CallObjectMethod(activityListener, "onPause", pause);
}
private void SetApplicationState() {
if (activityListener == null) {
// using (var listenerClass = GetClass(ActivityListenerClass)) { ###
// CallStaticMethod(listenerClass, "setUnityApplicationState"); ###
// } #####
}
}
}
}
/// @endcond
#endif // UNITY_ANDROID && !UNITY_HAS_GOOGLEVR
我有一个奇怪的场景,所以如果你启用了 vr 模式并且这不起作用,你也可以尝试评论 SetVRModeEnabled() 函数的主体