团结纸板方向横向右颠倒 [英] Unity Cardboard Orientation Landscape Right Upside Down

查看:311
本文介绍了团结纸板方向横向右颠倒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有一个使用谷歌纸板SDK,使立体视图,所以我将有一个VR功能的应用程式一个统一的应用程序。我的应用程序运行完全正常。

Hi I have a Unity app which uses google Cardboard SDK to enable stereoscopic view so I will have a VR enabled app. My app runs perfectly fine.

但是,如果我设置了播放器设置方向为汽车方向只留下山水和山水允许右一个问题。当它处于横向离开,一切工作按正常,但是当它处于横向右纸板视图将转180度(设置按钮移动到屏幕底部),但我的团结对象没有。因此,我有一个倒置的对象。

But there is a problem if I set the player settings orientation to be auto orientation with only landscape left and landscape right allowed. When it is in landscape left, everything works as per normal but when it is in landscape right the cardboard view will turn 180 degrees (settings button moved to bottom of screen) but my unity objects does not. Thus I have an upside-down objects.

任何解决这一问题的方法?

Any method to fix this?

感谢。

推荐答案

看来,SDK用来读取陀螺仪是硬编码仅供景观左方向的本地代码。这可以通过编辑BaseCardboardDevice.cs并用下面的代码替换UpdateState()的定义中工作围绕:

It appears the native code that the SDK uses to read the gyro is hardcoded for Landscape Left orientation only. This can be worked around by editing BaseCardboardDevice.cs and replacing the definition of UpdateState() with the following code:

private Quaternion fixOrientation;

public override void UpdateState() {
  GetHeadPose(headData, Time.smoothDeltaTime);
  ExtractMatrix(ref headView, headData);
  headPose.SetRightHanded(headView.inverse);

  // Fix head pose based on device orientation (since native code assumes Landscape Left).
  switch (Input.deviceOrientation) {
    case DeviceOrientation.LandscapeLeft:
      fixOrientation = Quaternion.identity;
      return;
    case DeviceOrientation.LandscapeRight:
      fixOrientation = Quaternion.Euler(0, 0, 180);
      break;
  }
  headPose.Set(headPose.Position, headPose.Orientation * fixOrientation);
}



我建议在关闭颈部模型尺寸(将其设置为0)纸板设置也一样,因为它不会与此代码出来的权利。

I suggest turning off the Neck Model Scale (set it to 0) in the Cardboard settings too, since it won't come out right with this code.

这篇关于团结纸板方向横向右颠倒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆