0

每次我构建时,它都会变回肖像。我找不到在哪里禁用此自动更改。有可能吗?

4

1 回答 1

0

进入播放器设置,将方向设置为自动旋转以外的任何内容,它不会改变。

您还可以以编程方式更改方向。只需确保在加载 AR 场景之前将其设置回固定方向即可。例如,如果您希望在非 AR 场景中启用自动旋转,您可以设置 Screen.orientation = ScreenOrientation.AutoRotation,然后在加载您的 AR 场景之前,只需将其设置回纵向或横向。

如果您想花哨的话,您还可以在用户按下用于启动 AR 场景的任何按钮时自动检测设备的方向,方法是首先检查 Input.deviceOrientation,然后将 Screen.orientation 设置为此。

这是一个示例 - Run() 函数启动您的场景(在首先检查设备方向并基于此设置屏幕方向之后):

void Run(String scene) {
      // Lock orientation to current device orientation prior to loading AR scene 
      switch (Input.deviceOrientation) {
        case DeviceOrientation.Portrait:
          Screen.orientation = ScreenOrientation.Portrait;
          break;
        case DeviceOrientation.PortraitUpsideDown:
          Screen.orientation = ScreenOrientation.PortraitUpsideDown;
          break;;
        case DeviceOrientation.LandscapeLeft:
          Screen.orientation = ScreenOrientation.LandscapeLeft;
          break;;
        case DeviceOrientation.LandscapeRight:
          Screen.orientation = ScreenOrientation.LandscapeRight;
          break;;
        default:
          // if Unknown, just set to Portrait
          Screen.orientation = ScreenOrientation.Portrait;
          break;
      }
    SceneManager.LoadScene(scene);
  }
于 2018-09-24T18:32:06.283 回答