如何使用 Unity 为 Oculus Quest 2 设置快速开发工作流程(即插即用)

发布于 2025-01-20 17:53:58 字数 77 浏览 2 评论 0原文

我该如何设置 Unity 和 Oculus,以便可以在 Unity 中点击“播放”并立即查看结果,而不是在 Oculus 上构建和运行游戏?

How would I go about setting up Unity and Oculus so I can hit Play in Unity and see the results immediately instead of building and running the game on Oculus?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落日海湾 2025-01-27 17:53:58

首先,这些是 Essentials 为了为Oculus Quest 2提供Unity所需的需求。完成这些步骤后,如果需要,可以执行其他步骤以具有最快的工作流程。

Unity方面:

  1. 安装Unity(2018年以上的任何内容都可以使用,最好是最新功能)。检查Android构建支持模块以及Android SDK& NDK和OpenJDK复选框。
  2. 打开一个新的3D空项目。 (最好是为Android平台打开它)
  3. 在构建设置中,切换到Android平台。 (如果尚未)
  4. 安装XR插件管理和Oculus XR插件
  5. 在软件包管理器中,在项目设置中 - > XR插件管理,转到“ Android”选项卡并检查Oculus选项。等待导入完成。

对于Oculus方面:

  1. 将Oculus开发人员帐户
  2. 放在您的任务2耳机上并登录开发人员帐户。
  3. 在您的任务2耳机中,转到设置 - >系统 - >开发人员并打开“ USB连接”对话框选项。另外,您可以使用Oculus Android应用程序进行操作。做一个或另一个。
  4. 使用USB-C连接到PC/笔记本电脑到USB电缆(例如Oculus Link电缆,但也将与第三方电缆一起使用),并接受显示的所有对话,即“允许USB调试“,“始终从这台计算机允许”,以及“允许访问数据”。

最终,在构建设置中的团结 - >运行设备从选项中选择连接的Oculus设备,然后单击“构建”&运行(确保您至少添加了一个场景来构建设置)。这将构建应用程序并将其推向您的Oculus(如果通过USB连接)。当您将耳机戴上时,您会看到应用程序负载。

就是这样。这是您需要为Oculus开发VR游戏所需的最低限度。但是,当然,如果我们留下它,那将是非常缓慢且乏味的开发VR应用程序,因为我们将必须自己编码基本的VR原则,并浪费时间来构建和将应用程序推到设备上,每次我们想更改和更改和测试一些东西。因此,我们将安装更多内容,以加快开发的速度。

  1. 安装Oculus开发人员中心。这将使您可以检查设备是否正确连接到PC,并且还具有其他功能(您可以直接从设备筛选和录制视频)。安装后,将设备与USB-C连接到USB电缆,并确保它在Oculus开发人员集线器中正确显示。 (此步骤不是必须的,但我建议)
  2. 安装oculus应用程序为Quest 2。您可以在Oculus网站上找到它。我们需要此功能才能使Oculus链接功能工作,这将使我们能够实时测试,而不是在Oculus上构建和运行该应用程序。
  3. 运行Oculus应用程序,当您这样做时,它将显示一个设置指南。遵循指南。您可以通过电缆(电缆链路)或WiFi(Airlink)选择连接。
  4. 在连接的Oculus耳机中,会弹出对话,询问您是否希望启用Oculus链接。接受它。
  5. 在Unity中,转到包装管理器并安装XR交互工具包。该插件大大减少了设置VR钻机的麻烦。
  6. 在新的场景中,右键单击层次结构,请转到Xr->基于设备的 - > XR钻机(也可以说XR Origin)
  7. 单击“统一播放”并戴上耳机。您应该在Unity编辑器中看到耳机和控制器的跟踪。

对于开发方面来说,这几乎就是它。如果您想为Oculus构建,您只需要去构建设置,然后在运行设备选项中选择连接的Oculus Quest 2设备,然后单击“构建”和“构建和运行”。当然,用XR钻机保存场景,并将其添加到建立设置。

测试以与ASUS TUF笔记本电脑上的Unity 2020.3.25F1合作。

如果您遇到障碍,请随时在某些步骤上纠正我。希望拥有尽可能全面的指南。

First off, these are the essentials one needs in order to develop for Oculus Quest 2 with Unity. After completing these steps, you can, if you want, do the other ones to have the fastest possible workflow.

Unity side:

  1. Install Unity (anything above 2018 would work, preferably the latest). Check the Android Build Support module, as well as the Android SDK & NDK and OpenJDK checkboxes.
  2. Open a new 3d empty project. (preferably open it for the Android platform)
  3. In Build Settings, switch to Android platform. (if it's not already)
  4. In the Package Manager, install the XR Plugin Management and the Oculus XR Plugin
  5. In Project Settings -> XR Plugin Management, go the Android tab and check the Oculus option. Wait for the import to finish.

For the Oculus side:

  1. Make an Oculus Developer account
  2. Put on your Quest 2 headset and log in to your developer account.
  3. In your Quest 2 headset, go to Settings -> System -> Developer and turn on the USB Connection Dialog option. Alternatively, you can do the same with the Oculus Android app. Do one or the other.
  4. Connect the headset to the pc/laptop with a usb-c to usb cable (like the Oculus Link cable, but it will work with third-party cables as well) and accept all the dialogues that show up, namely the "Allow USB Debugging", "Always allow from this computer", and the "Allow access to data".

Finaly, In Unity in Build Settings -> Run Device choose the connected Oculus device from the options and click Build & Run (make sure you have at least one scene added to Build Settings). This will build the application and push it to your Oculus (if connected via usb). When you put your headset on you will see the application load.

That's it. This is the bare minimum you need in order for you to develop VR games for Oculus. But of course if we leave it at that it's going to be really slow and tedious developing VR apps because we will have to code basic VR principles by ourselves and waste time on building and pushing the app to the device every time we want to change and test something. And so, we are going to install a few more things in order to speed up development.

  1. Install the Oculus Developer HUB. This will allow you to check if your device is connected to the PC properly, and also has other functionalities (you can screen capture and record video directly from the devices). Once installed, connect your device with a usb-c to usb cable and make sure it shows properly in the Oculus Developer HUB. (this step is NOT a must but I recommend it)
  2. Install the Oculus App for Quest 2. You can find it on Oculus website. We need this in order for the Oculus Link feature to work, which will allow us to test in real time instead of building and running the app on the Oculus.
  3. Run the Oculus App, and when you do it will show a setup guide. Follow the guide. You can choose connection via cable (cable link) or via wifi (AirLink).
  4. In your connected Oculus headset, a dialogue will pop up asking you if you wish to enable Oculus Link. Accept it.
  5. In Unity, go to Package Manager and install the XR Interaction Toolkit. This plugin greatly lessens the troubles of setting up a VR rig.
  6. In a new scene right click in the Hierarchy, go to XR -> Device-based -> XR Rig (could also say XR Origin)
  7. Click Play in Unity and put on your headset. You should see the tracking of the headset and controllers mirror in the Unity editor.

That's pretty much it for the development side. If you wish to build for Oculus, you just have to go to Build Settings and in the Run Device option choose the connected Oculus Quest 2 device and click Build and Run. And of course save the scene with the XR Rig and add it to Build Settings.

Tested to work with Unity 2020.3.25f1 on ASUS TUF laptop.

Feel free to correct me on some of the steps if you hit an obstacle. Would love to have as comprehensive guide as possible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文