【问题标题】:Google VR Unity Divider, Settings and Back button hiding in v0.9Google VR Unity Divider、设置和返回按钮隐藏在 v0.9
【发布时间】:2019-04-16 16:45:30
【问题描述】:

有谁知道如何在最新的 google vr sdk for unity 中禁用 Divider、设置和后退按钮?

我尝试将 NativeUILayerSupported 设置为 false 并在旧版 DrawUILayer 中添加一个返回值,但它仍然显示。

看来,旧的做法现在已完全弃用。

【问题讨论】:

  • “看来旧的做法现在已完全弃用”旧的做法是什么?
  • 以前版本的 SDK 在 Cardboard 相机预制件上只有一个复选框(可能是下拉菜单),用于选择是否显示后退按钮。您仍然可以通过浏览 github repo 中的标签找到旧版本的 SDK。

标签: android unity3d google-vr


【解决方案1】:

对于 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;
}

【讨论】:

    【解决方案2】:

    尝试禁用 UI 层设置Cardboard 脚本上的设置为 false。

    从界面而不是代码中执行此操作。

    【讨论】:

      【解决方案3】:

      我使用的是适用于 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);
      

      【讨论】:

        【解决方案4】:

        @PerryHart 我在使用 Google VR SDK 时遇到了同样的问题。问题是在最新版本的 GVR SDK 中没有禁用按钮和其他 UI 层的接口。但是 Google VR SDK 0.8 和低于 0.8 提供了接口,您可以通过它轻松完成。

        从代码中禁用这些层非常复杂,我浪费了 2 周的时间来通过 GVR 1.xx 版本中的代码来做这些事情。

        你可以下载Google VR SDK 0.8.1 from here.

        【讨论】:

          【解决方案5】:

          我的场景:

          • 带有 Gvr 的 Gvr-Ar 应用程序仅适用于陀螺仪(Gvr 眼睛不是渲染事物,使用自己的相机)
          • 评论了整个后期渲染器类(这也意味着我没有计算镜头失真,并且可以在没有相机镜头形状的情况下使用全屏)

          什么对我有用(使用 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() 函数的主体

          【讨论】:

          • 实际上评论或删除这些很重要:activityListener = Create(ActivityListenerClass);
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多