使用 HoloLens 仿真器Using the HoloLens Emulator

HoloLens 仿真器包括 HoloLens 开发工具集,可让你在未配备物理 HoloLens 的电脑上测试全息应用程序。The HoloLens Emulator lets you test holographic applications on your PC without a physical HoloLens, including the HoloLens development toolset. 该仿真器使用 Hyper-V 虚拟机,这意味着 HoloLens 传感器读取的人类和环境输入通过键盘、鼠标或 Xbox 控制器模拟。The emulator uses a Hyper-V virtual machine, which means human and environmental inputs being read by HoloLens sensors are simulated from your keyboard, mouse, or Xbox controller. 项目甚至无需经过修改即可在仿真器上运行,并且应用不知道其不是在真实的 HoloLens 上运行。You don't even need to modify your projects to run on the emulator, the app doesn't know it isn't running on a real HoloLens.

如果想要开发适用于台式机的 Windows Mixed Reality 沉浸式 (VR) 头戴显示设备应用程序或游戏,请查看 Windows Mixed Reality 模拟器,该设备可用于模拟桌面头戴显示设备。If you're looking to develop Windows Mixed Reality immersive (VR) headset applications or games for desktop PCs, check out the Windows Mixed Reality simulator, which lets you simulate desktop headsets.

HoloLens 2 仿真器概述HoloLens 2 Emulator Overview

安装 HoloLens 仿真器Installing the HoloLens Emulator

下载 HoloLens 仿真器。Download the HoloLens Emulator.

版本:Versions:

可以在 HoloLens 仿真器存档页上找到 HoloLens 仿真器的发行说明和旧版本。You can find release notes and older builds of the HoloLens Emulator on the HoloLens Emulator archive page.

HoloLens 仿真器系统要求HoloLens Emulator system requirements

HoloLens 仿真器结合使用 Hyper-V 和 RemoteFx(第 1 代仿真器)或 GPU-PV(HoloLens 2 仿真器)来实现图形硬件加速。The HoloLens Emulator uses Hyper-V with RemoteFx (first Gen Emulator) or GPU-PV (HoloLens 2 Emulator) for hardware accelerated graphics. 若要使用仿真器,请确保电脑符合以下硬件要求:To use the emulator, make sure your PC meets the following hardware requirements:

  • 64 位 Windows 10 专业版、企业版或教育版64-bit Windows 10 Pro, Enterprise, or Education

    备注

    Windows 10 家庭版不支持 Hyper-V 或 HoloLens 仿真器。Windows 10 Home Edition does not support Hyper-V or the HoloLens Emulator.
    HoloLens 2 仿真器需要 Windows 10 2018 年 10 月更新版或更高版本。The HoloLens 2 Emulator requires the Windows 10 October 2018 update or later.

  • 64 位 CPU64-bit CPU
  • 4 核 CPU(或总共有 4 个核心的多个 CPU)CPU with four cores (or multiple CPUs with a total of four cores)
  • 8 GB 或更大的 RAM8 GB of RAM or more
  • 在 BIOS 中,必须支持且启用以下功能:In the BIOS, the following features must be supported and enabled:
    • 硬件协助的虚拟化Hardware-assisted virtualization
    • 二级地址转换 (SLAT)Second Level Address Translation (SLAT)
    • 基于硬件的数据执行保护 (DEP)Hardware-based Data Execution Prevention (DEP)
  • GPU 要求GPU requirements
    • DirectX 11.0 或更高版本DirectX 11.0 or later
    • WDDM 1.2 图形驱动程序或更高版本(第 1 代)WDDM 1.2 graphics driver or later (first gen)
    • WDDM 2.5 图形驱动程序(HoloLens 2 仿真器)WDDM 2.5 graphics driver (HoloLens 2 Emulator)
    • 仿真器可与不受支持的 GPU 配合工作,但速度会变慢The emulator might work with an unsupported GPU, but will be slower

如果你的系统满足上面列出的要求,请确保已在系统上启用“Hyper-V”功能。If your system meets the requirements listed above, ensure that the "Hyper-V" feature has been enabled on your system. 转到“控制面板”->“程序”->“程序和功能”->“打开或关闭 Windows 功能”,并检查是否选中了“Hyper-V” 。Go to Control Panel -> Programs -> Programs and Features -> Turn Windows Features on or off and check that Hyper-V is selected.

将应用部署到 HoloLens 仿真器Deploying apps to the HoloLens Emulator

  1. 在 Visual Studio 中加载应用程序解决方案。Load your application solution in Visual Studio.

    备注

    使用 Unity 时,请从 Unity 生成项目,然后像往常一样将生成的解决方案载入 Visual Studio。When using Unity, build your project from Unity and then load the built solution into Visual Studio, as usual.

  2. 对于 HoloLens 仿真器(第 1 代),请确保将“平台”设置为“x86”。For HoloLens Emulator (first gen), ensure that Platform is set to x86. 对于 HoloLens 2 仿真器,请确保将“平台”设置为“x86”或“x64”。 For the HoloLens 2 Emulator, ensure that the Platform is set to x86 or x64.
  3. 选择所需的 HoloLens 仿真器版本作为目标调试设备。Select the HoloLens Emulator version you want as the target device for debugging.
  4. 转到“调试”>“开始调试”或按 F5 启动仿真器,然后部署要调试的应用程序。Go to Debug > Start Debugging or press F5 to launch the emulator and deploy your application for debugging.

仿真器在首次启动时,可能需要花费一分钟或更长的时间来完成引导。The emulator may take a minute or more to boot when you first start it. 建议在调试会话期间让仿真器保持打开状态,以便将应用程序快速部署到仿真器。We recommend that you keep the emulator open during your debugging session, so that you can quickly deploy applications to the emulator.

基本的仿真器输入Basic emulator input

控制仿真器与控制许多常见的 3D 视频游戏相似。Controlling the emulator is similar to many common 3D video games. 可以通过输入选项来使用键盘、鼠标或 Xbox 控制器。Input options are available for using the keyboard, mouse, or Xbox controller. 通过定向佩戴 HoloLens 的模拟用户执行的操作来控制仿真器。You control the emulator by directing the actions of a simulated user by wearing a HoloLens. 你的操作可在环境中四处移动该模拟用户。Your actions move the simulated user around the environment. 仿真器中运行的应用程序可以像在真实设备上一样做出响应。Applications running in the emulator respond like they would on a real device.

HoloLens(第 1 代)上的光标可跟踪头部运动和旋转。The cursor on HoloLens (first gen) follows head movement and rotation. 在 HoloLens 2 仿真器中,光标跟踪手部运动和方向。In the HoloLens 2 Emulator, the cursor follows hand movement and orientation.

  • 前后左右走动 - 使用键盘上的 WASD 键,或 Xbox 控制器上的左摇杆。Walk forward, back, left, and right - Use the W,A,S, and D keys on your keyboard, or the left stick on an Xbox controller.
  • 上下左右注视 - 选择并拖动鼠标、使用键盘上的箭头键,或使用 Xbox 控制器上的右摇杆。Look up, down, left, and right - Select and drag the mouse, use the arrow keys on your keyboard or the right stick on an Xbox controller.
  • 隔空敲击手势 - 单击鼠标右键、按键盘上的 Enter 键,或使用 Xbox 控制器上的 A 按钮。Air tap gesture - Right-click the mouse, press the Enter key on your keyboard or use the A button on an Xbox controller.
  • 开花手势/系统手势 - 按键盘上的 Windows 键或 F2 键,或按 Xbox 控制器上的 B 按钮。Bloom/System gesture - Press the Windows key or F2 key on your keyboard or press the B button on an Xbox controller.
  • 滚动时的手部运动 - 按住 Alt 键和鼠标右键的同时向上或向下拖动鼠标。Hand movement for scrolling - Simultaneously hold the Alt key and the right mouse button, and drag the mouse up or down. 在 Xbox 控制器中按住右扳机键和 A 按钮的同时向上和向下移动右摇杆。In an Xbox controller, hold down the right trigger and A button and move the right stick up and down.
  • 手部运动和方向(仅适用于 HoloLens 2 仿真器)- 按住 Alt 键的同时向上、向下、向左或向右拖动鼠标以移动手部。Hand movement and orientation (HoloLens 2 Emulator only) - Hold the Alt key and drag the mouse up or down, left or right to move the hand. 也可以使用箭头键和 Q 或 E 来旋转和倾斜手部。You can also use the arrow keys and Q or E to rotate and tilt the hand. 在 Xbox 控制器中,请在按住左缓冲键或右缓冲键的同时,使用左拇指操纵杆向左、向右、向前和向后移动手部,使用右拇指操纵杆旋转手部。For an Xbox controller, hold the left or right bumper and use the left thumbstick to move the hand left, right, forward, and back, the right thumbstick to rotate it. 使用 Dpad 上的向上或向下键来抬高或降低手部。Use up or down on the Dpad to raise or lower the hand.

有 Windows Mixed Reality 沉浸式头戴显示设备?Have a Windows Mixed Reality immersive headset? 从 HoloLens 2 仿真器(Windows 全息版 2004)开始,可以使用 Windows Mixed Reality 沉浸式头戴显示设备和运动控制器来控制 HoloLens 2 仿真器,并以立体方式观看它。Starting with the HoloLens 2 Emulator (Windows Holographic, version 2004), you can use your Windows Mixed Reality immersive headset and motion controllers to control the HoloLens 2 Emulator and view it in stereo. 请参阅将 Windows Mixed Reality 沉浸式头戴显示设备和运动控制器与 HoloLens 2 仿真器配合使用See Using a Windows Mixed Reality immersive headset and motion controllers with the HoloLens 2 Emulator

HoloLens 2 仿真器剖析Anatomy of the HoloLens 2 Emulator

主窗口Main window

HoloLens 2 仿真器主窗口

工具栏Toolbar

在主窗口的右侧,可以看到仿真器工具栏。To the right of the main window, find the emulator toolbar. 工具栏包含以下按钮:The toolbar contains the following buttons:

  • “关闭”图标 关闭:关闭仿真器。Close icon Close: Closes the emulator.
  • “最小化”图标 最小化:最小化仿真器窗口。Minimize icon Minimize: Minimizes the emulator window.
  • “模拟”图标 模拟控制面板:显示或隐藏 模拟控制面板,以便配置和控制 仿真器的输入Simulation_icon Simulation control panel: Show or hide the Simulation control panel for configuring and controlling input to the emulator.
  • “适合屏幕大小”图标 适合屏幕大小:使仿真器适合屏幕大小。Fit to screen icon Fit to screen: Fits the emulator to screen.
  • “缩放”图标 缩放:放大和缩小仿真器。Zoom icon Zoom: Make the emulator larger and smaller.
  • “帮助”图标 帮助:打开仿真器帮助。Help icon Help: Open emulators help.
  • “打开设备门户”图标 打开设备门户:在仿真器中打开 HoloLens OS 的 Windows 设备门户。Open device portal icon Open Device Portal: Open the Windows Device Portal for the HoloLens OS in the emulator.
  • “工具”图标 工具:打开“其他工具”窗格。Tools icon Tools: Open the Additional tools pane.

模拟控制面板Simulation control panel

使用模拟控制面板可以查看模拟人类和输入设备的当前位置与方向。The Simulation control panel lets you view the current position and orientation of the simulated human and input devices. 使用它还可以配置模拟输入(例如,显示或隐藏一只或两只手)和用于控制模拟输入的设备(例如电脑的键盘、鼠标和游戏手柄)。It also allows you to configure both simulated input, such as showing or hiding one or both hands, and devices used for controlling simulated input, such as your PC's keyboard, mouse and gamepad.

模拟控制面板

  • 要隐藏或显示模拟面板,请选择工具栏按钮或按键盘上的 F7。To hide or show the simulation panel, select the toolbar button or press F7 on your keyboard.
  • 将鼠标悬停在控件或字段上可显示工具提示,其中包含键盘、鼠标和游戏手柄的控件。Hover the mouse over a control or field to display a tooltip that contains keyboard, mouse, and gamepad controls for it.
  • 若要显示或隐藏手部,请切换左手或右手下方的相应开关。To show or hide a hand, toggle the appropriate switch under Left hand or Right hand.
  • 若要控制手部,请使用键盘上的左/右 Alt 键,或游戏手柄上的左/右缓冲键。To control the hand, use either the left or right Alt keys on your keyboard or the left or right bumper on the gamepad.
  • 要将所有输入指向一只手或两只手,请选择切换开关下的图钉按钮,这相当于针对手部按住 Alt 键。To direct all input to one or both hands, select the pushpin button under the toggle switch, which is the same as holding the Alt key for the hand.
  • 要控制视线方向,请选择“眼睛”部分中的图钉,这相当于按住键盘上的 Y 键。To control eye gaze direction, select the pushpin in the Eyes section, which is the same as holding down the Y key on the keyboard.
  • 要加载房间录制内容,请选择“录制”部分中的“加载”按钮。To load a room recording, select the Load button in the Recording section. 有关详细信息,请参阅模拟的房间See simulated rooms for more information.
  • 要调整模拟人类或输入设备在响应键盘、鼠标或游戏手柄输入时移动或旋转的速度,请选择“输入设置”旁边的齿轮图标并调整滑块。To adjust the speed that the simulated human or input devices will move or rotate in response to keyboard, mouse or gamepad input, select the gear icon next to Input settings, and adjust the sliders.
  • 默认情况下,键盘输入会控制模拟人类和模拟输入。By default, keyboard input controls the simulated human and simulated input. 若要将电脑的键盘输入发送到 HoloLens,请取消选中“使用键盘进行模拟”。To have your PC's keyboard input sent through to the HoloLens, uncheck Use keyboard for simulation. F4 是此项设置的快捷键。F4 is the shortcut key for this setting.
  • 如果模拟面板已显示,按 F8 会将键盘焦点转移到模拟面板。If the simulation panel is already visible, pressing F8 moves keyboard focus into it.
  • 要在仿真器窗口中取消停靠模拟面板,请选择面板底部的按钮,或按键盘上的 F9。To undock the simulation panel from the emulator window, select the button at the bottom of the panel or press F9 on your keyboard. 关闭窗口或再次按 F9 会恢复为仿真器窗口。Closing the window or pressing F9 again returns the window to the emulator.
  • 可将模拟控制面板作为单独的应用程序启动,这样就可以通过运行 %ProgramFiles(x86)%\Windows Kits\10\Microsoft XDE\10.0.18362.0\ 中的 PerceptionSimulationInput.exe,来连接和控制 HoloLens 2 仿真器、HoloLens 2 设备或 Windows Mixed Reality 模拟。The simulation control panel can be launched as a separate application, allowing you to connect to and control the HoloLens 2 Emulator, a HoloLens 2 device, or Windows Mixed Reality simulation by running PerceptionSimulationInput.exe from %ProgramFiles(x86)%\Windows Kits\10\Microsoft XDE\10.0.18362.0.

“帐户”选项卡Account tab

在“帐户”选项卡中,可将仿真器配置为使用 Microsoft 帐户登录。The Account tab lets you configure the emulator to sign in with a Microsoft Account. 在测试需要用户使用帐户登录的 API 时,此配置非常有用。This is useful for testing APIs that require the user to be signed in with an account. 切换此选项需要完全关闭并重启 HoloLens 仿真器,使设置生效。Toggling this option requires that you completely close and restart the HoloLens Emulator for the setting to take effect. 如果启用此选项,则后续启动仿真器时,系统会要求你登录,就像用户首次启动 HoloLens 时一样。If this option is enabled, later launches of the emulator will ask you to sign in, just like a user would the first-time HoloLens is started. 若要使用电脑键盘输入凭据,请先在模拟控制面板中关闭“使用键盘进行模拟”,或按键盘上的 F4 打开或关闭键盘设置。To enter your credentials using your PC's keyboard, first turn off Use keyboard for simulation in the Simulation Control Panel or press F4 on your keyboard to toggle the keyboard setting on or off.

“可选设置”选项卡Optional settings tab

“可选设置”选项卡显示用于启用或禁用硬件加速图形的控件。The Optional settings tab displays a control to enable or disable hardware accelerated graphics. 默认情况下,如果电脑的图形适配器驱动器支持硬件加速图形,则会使用硬件加速图形。Hardware accelerated graphics are used by default, if supported by your PC's graphics adapter drive. 如果图形适配器的驱动程序不支持 GPU-PV,则不会显示此选项。If your graphics adapter's driver doesn't support GPU-PV, this option won't be visible.

“诊断”选项卡Diagnostics tab

“诊断”选项卡以 Windows 设备门户链接的形式显示仿真器的 IP 地址,以及虚拟 GPU 的状态。The Diagnostics tab shows the emulator's IP address in the form of a link to Windows Device Portal along with the status of the virtual GPU.

“网络”选项卡Network tab

“网络”选项卡显示仿真器的网络适配器详细信息,以及主机的网络适配器详细信息。The Network tab shows the network adapter details for the emulator, as well as network adapter details for the host machine. 对于 HoloLens 2 仿真器,只有在 Windows 10 2019 年 5 月更新版或更高版本上运行此仿真器时,此选项卡才会显示。For the HoloLens 2 Emulator, this tab will only appear when running the emulator on the Windows 10 May 2019 Update or newer.

“NAT 配置”选项卡NAT Configuration tab

只有在 Windows 10 2019 年 5 月更新版或更高版本上运行此仿真器时,此选项卡才会显示。This tab will only appear when running the emulator on the Windows 10 May 2019 Update or newer.

此仿真器使用电脑的网络连接,位于 NAT 后面。The emulator uses your PC's network connection and sits behind a NAT. 可以通过此选项卡将端口从主机电脑映射到仿真器,使远程设备能够连接到在仿真器中运行的应用程序和服务。This tab allows you to map ports from your host PC to the emulator, which enables remote devices to connect to applications and services running in the emulator.

例如,如果需要从远程电脑访问仿真器上的设备门户,请执行以下操作:For example, if you want to access Device Portal on the emulator from a remote PC:

  1. 通过双击表中的可用行,为内部端口 80(设备门户在其上进行侦听的端口)添加一个条目。Add an entry for internal port 80 (the port on which Device Portal is listening) by double-clicking on a free row in the table. 对于其他应用程序,请输入应用程序正在其上侦听的端口号。For other applications, enter the port number on which that application is listening.
  2. 选择任何可用的外部端口。Choose any available external port. 在此示例中,我们将使用端口 8080 作为外部端口。In this example, we'll use port 8080 as the external port.
  3. 选择协议。Select the protocol. 默认协议为 TCP。The default is TCP. 由于设备门户使用 TCP,我们会保留默认设置。Since Device Portal uses TCP, we'll leave the default.
  4. 单击“应用更改”以启用映射。Click "Apply Changes" to enable the mapping. “状态”会从“挂起”更改为“活动”。The 'Status' will change from 'Pending' to 'Active'.
  5. 在远程电脑上打开浏览器,导航到“(运行仿真器的电脑的 IP):8080”。On the remote PC, open a browser and navigate to (IP-of-the-PC-running-the-emulator):8080. 此时会显示设备门户界面。The Device Portal interface will appear. 在远程电脑上使用的 IP 地址必须是运行仿真器的电脑的 IP 地址,而不是仿真器本身的 IP 地址。The IP address you use on a remote PC must be the IP address of the PC running the emulator, not of the emulator itself. 可以通过各种方式检索 IP,例如,在电脑上的“设置应用”的“网络和 Internet”类别中检索、在命令提示符中使用“ipconfig”进行检索,以及在仿真器的“工具”对话框的“网络”选项卡中通过查找“桌面适配器”条目进行检索。You can retrieve the IP through various means such as the Settings app on the PC in the 'Network & Internet' category, 'ipconfig' from a Command Prompt and from the Network tab in the emulator Tools dialog by looking for the Desktop Adapter entry.

另请注意,如果为设备门户添加端口映射,则可以远程方式控制仿真器,方法是:使用包括在仿真器安装中的“感知模拟控制”工具,或者使用感知模拟 API,只需连接到主机电脑的 IP 地址和设备门户的外部端口(例如以上示例中的 8080)即可。Also note that if you add a port mapping for Device Portal, you can control the emulator remotely using the Perception Simulation Control tool included in the emulator installation or with the Perception Simulation APIs by connecting to the host PC's IP address and Device Portal external port, such as 8080 in the example above. 使用感知模拟控制连接到仿真器并对其进行远程控制时,请仅指定电脑的 IP 地址和配置的端口。When using Perception Simulation Control to connect to and control the emulator remotely, only specify the PC's IP address and the configured port. 不要包含“https://”。Don't include 'https://'.

默认情况下,没有端口映射。There are no port mappings by default. 多次启动 HoloLens 2 仿真器时,配置的任何映射都会保持不变,并且会在仿真器完全启动后自动启用。Any mappings you configure are persistent across launches of the HoloLens 2 Emulator and will be enabled automatically when the emulator has booted fully.

请使用“导出”按钮将映射保存到文件。Use the 'Export' button to save your mappings to a file. 然后,可以将此文件与其他可以使用“导入”按钮自动配置相同映射的团队成员共享。You can then share this file with other team members who can use the 'Import' button to automatically configure the same mappings.

HoloLens 仿真程序的“NAT 配置”选项卡

“更新”选项卡Updates tab

只有在 Windows 10 2019 年 5 月更新版或更高版本上运行此仿真器时,此选项卡才会显示。This tab will only appear when running the emulator on the Windows 10 May 2019 Update or newer.

启动时,仿真程序会检查是否有新版本。On startup, the emulator will check for new versions. 如果有可用的新版本,仿真程序会显示一个提示(其中会显示你的现有版本和可用版本),并询问你是否希望更新。If a new version is available, the emulator will display a prompt showing the version you have, along with the available version and asking if you want to update. 如果你选择“是”,系统会下载新版本的安装程序。If you select 'Yes', the installer for the new version is downloaded.

使用“更新”选项卡,你可以通过在其上切换“自动检查更新”复选框来控制是否允许仿真程序检查新版本。还可以通过它查看和下载其他可用的仿真程序版本(从 2019 年 9 月更新版开始)。The Updates tab allows you control whether or not the emulator checks for new versions by toggling the "Automatically check for updates" check box on this tab. It also allows you to see and download other available emulator versions, starting with the September 2019 Update. 除当前正在运行的版本之外的其他版本都提供了下载链接。For versions other than the one currently running, a download link is provided. 单击该链接会下载该版本的安装程序。Clicking this link will download the installer for that version.

HoloLens 仿真器的“更新”选项卡

将 Windows Mixed Reality 沉浸式头戴显示设备和运动控制器与 HoloLens 2 仿真器配合使用Using a Windows Mixed Reality immersive headset and motion controllers with the HoloLens 2 Emulator

从 HoloLens 2 仿真器(Windows 全息版 2004)开始,可以使用 Windows Mixed Reality 沉浸式头戴显示设备和运动控制器,以立体方式观看 HoloLens 2 仿真器并与之交互。Starting with the HoloLens 2 Emulator (Windows Holographic, version 2004), you can use a Windows Mixed Reality headset and motion controllers to view and interact with the HoloLens 2 Emulator in stereo. 这样,你便可以在没有 HoloLens 2 设备的情况下利用头部和手部进行更快、更自然的运动。This allows you to make faster, more natural movements with your head and hands without a HoloLens 2 device. 这并非用于完全替代 HoloLens 2 设备,而是旨在提供改善的体验,使用户不仅仅能够在 2D 桌面窗口中使用键盘、鼠标和手柄与仿真器进行交互。It isn't a complete replacement for a HoloLens 2 device, but is intended to give an improved experience beyond interacting with the emulator using keyboard, mouse and gamepad in a 2D desktop window. 若要启用此功能:To enable this feature:

  1. 请确保在电脑上配置了 Windows Mixed Reality,并且连接了 Windows Mixed Reality 沉浸式头戴显示设备。Ensure that Windows Mixed Reality is configured on your PC and your Windows Mixed Reality immersive headset is connected.
  2. 启动 HoloLens 2 仿真器Launch the HoloLens 2 Emulator
  3. 单击工具栏按钮或按 F7 打开“仿真”面板。Open the Simulation panel by clicking the toolbar button or pressing F7.
  4. 向下滚动到面板底部。Scroll the panel to the bottom.
  5. 选中标记了“使用 HMD 进行仿真”的框Check the box labeled "Use HMD for simulation"
  6. Windows Mixed Reality 将启动,并且仿真器显示内容将略有变化。Windows Mixed Reality will start and the emulator display will change slightly. 如果未使用头戴显示设备,仿真器会将两只眼睛置于头部中心,并且只显示一只眼睛。Without a headset, the emulator places both eyes in the center of the head and displays only one eye. 如果使用了头戴显示设备,仿真器会生成真正的立体输出,但只会在其桌面窗口中呈现一只眼睛,而会在头戴显示设备中呈现两只眼睛。With a headset, the emulator generates true stereo output but only renders one eye to its desktop window, while both eyes are rendered to your headset.
  7. 可以选择启用一个或两个运动控制器。Optionally turn on one or both motion controllers. 控制器输入映射到仿真器中的手动输入。Controller input is mapped to hand input in the emulator. 例如,若要点击,请在运动控制器上按下扳机键。For example, to tap, pull the trigger on the motion controller. 若要四处移动,请使用控制杆。To move around, use the thumbstick. 有关控制的完整列表,请参阅高级 HoloLens 仿真器和混合现实仿真器输入For a complete list of controls, see Advanced HoloLens Emulator and Mixed Reality Simulator input

在头戴显示设备中查看内容时遇到问题?Having trouble seeing content in your headset?

  • 如果显示内容在头戴显示设备和混合现实门户中均为空白,但你在桌面上的“HoloLens 2 仿真器”窗口中看到了内容,请验证是否在仿真器中启用了硬件图形加速。If the display is blank in both the headset and Mixed Reality Portal, but you see content in the HoloLens 2 Emulator window on your desktop, verify that hardware graphics acceleration is enabled in the emulator. Windows Mixed Reality 沉浸式头戴显示设备支持要求在仿真器中启用硬件图形加速。Windows Mixed Reality immersive headset support requires hardware graphics acceleration to be enabled in the emulator.
  • 如果在头戴显示设备中看到内容,但全息影像比较模糊,或者你看到双像,请使用以下步骤为你的眼睛调整立体视图:If you see content in the headset but holograms are blurry or you see a double image, use the following steps to adjust the stereo view for your eyes:
  1. 暂时禁用“使用 HMD 进行仿真”。Temporarily turn off "Use HMD for simulation".
  2. 启动注册表编辑器 (regedit.exe)Launch Registry Editor (regedit.exe)
  3. 导航到 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\PerceptionSimulationNavigate to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\PerceptionSimulation
  4. 创建一个名为“EnableEyePoseControl”的新 DWORD 值,并将其值设置为 1。Create a new DWORD value named "EnableEyePoseControl" and set its value to 1.
  5. 在仿真器中启用“使用 HMD 进行仿真”。Enable "Use HMD for simulation" in the emulator.
  6. 当内容显示在头戴显示设备中时,使用箭头键调整眼睛转动。When content appears in the headset, use the arrow keys to adjust eye rotation. 按住左 Alt 键可调整左眼,按住右 Alt 键可调整右眼。Hold Left Alt to adjust the left eye and Right Alt to adjust the right eye. 使用“Q”和“E”为每个眼睛调整转动,同时再次按住适用于该眼睛的 Alt 键。Use 'Q' and 'E' to adjust the roll for each eye, again holding the appropriate Alt key for the eye. 使用“+”和“-”键调整眼睛之间的距离。Use the '+' and '-' keys to adjust the distance between the eyes. (请注意,数字键盘上的 +/- 不会起作用。(Note that +/- on a number pad will not work. 请使用主键盘上的按键。)Use the buttons on the main keyboard.)
  7. 当立体视图看起来正常时,请按“S”保存更改。When the stereo view appears correct, press 'S' to save your changes. 新配置将保存起来,以用于以后启动仿真器。The new configuration will be saved for future launches of the emulator.
  8. 如果要放弃所做的更改并恢复到以前的配置,请按“L”加载默认配置或以前的配置。If you want to abandon your changes and revert to the previous configuration, press 'L' to load the default or previous configuration.
  9. 在注册表中将“EnableEyePoseControl”值更改为 0,然后禁用“使用 HMD 进行仿真”选项并再次启用该选项。Change the "EnableEyePoseControl" value in the registry to 0 and cycle the "Use HMD for simulation" option.

如果已保存配置,并想要删除它,则可以在 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\PerceptionSimulation 下删除名为“DisplayConfiguration”的值。If you have saved a configuration and want to remove it, you can delete the value named "DisplayConfiguration" at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\PerceptionSimulation. 如果当前正在将头戴显示设备与仿真器配合使用,则需要禁用“使用 HMD 进行仿真”并将其重新启用,才能看到此更改生效。If you are currently using the headset with the emulator, you will need to turn off "Use HMD for simulation" and turn it back on to see this change take effect.

HoloLens(第 1 代)仿真器剖析Anatomy of the HoloLens (first gen) emulator

主窗口Main window

当仿真器启动时,你会看到一个显示 HoloLens OS 的窗口。When the emulator launches, you'll see a window, which displays the HoloLens OS.

HoloLens 仿真器主窗口

工具栏Toolbar

在主窗口的右侧,可以看到仿真器工具栏。To the right of the main window, you'll find the emulator toolbar. 工具栏包含以下按钮:The toolbar contains the following buttons:

  • “关闭”图标 关闭:关闭仿真器。Close icon Close: Closes the emulator.
  • “最小化”图标 最小化:最小化仿真器窗口。Minimize icon Minimize: Minimizes the emulator window.
  • “人类输入”图标 人类输入:使用鼠标和键盘来模拟 仿真器的人类输入Human input icon Human input: Mouse and keyboard are used to simulate human input to the emulator.
  • “键盘和鼠标输入”图标 键盘和鼠标输入:键盘和鼠标输入将作为键盘和鼠标事件直接传递给 HoloLens OS,就如同已连接蓝牙键盘和鼠标一样。Keyboard and mouse input icon Keyboard and mouse input: Keyboard and mouse input are passed directly to the HoloLens OS as keyboard and mouse events, as if you connected a Bluetooth keyboard and mouse.
  • “适合屏幕大小”图标 适合屏幕大小:使仿真器适合屏幕大小。Fit to screen icon Fit to screen: Fits the emulator to screen.
  • “缩放”图标 缩放:放大和缩小仿真器。Zoom icon Zoom: Makes the emulator larger and smaller.
  • “帮助”图标 帮助:打开仿真器帮助。Help icon Help: Opens emulator help.
  • “打开设备门户”图标 打开设备门户:在仿真器中打开 HoloLens OS 的 Windows 设备门户。Open device portal icon Open Device Portal: Open the Windows Device Portal for the HoloLens OS in the emulator.
  • “工具”图标 工具:打开“其他工具”窗格。Tools icon Tools: Open the Additional tools pane.

“模拟”选项卡Simulation tab

“其他工具”窗格中的默认选项卡是“模拟”选项卡。 The default tab within the Additional tools pane is the Simulation tab.

HoloLens 仿真器的“其他工具”窗格

“模拟”选项卡显示用于在仿真器中驱动 HoloLens OS 的模拟传感器的当前状态。The Simulation tab shows the current state of the simulated sensors used to drive the HoloLens OS within the emulator. 将鼠标悬停在“模拟”选项卡中的任一值上会显示工具提示,其中描述了如何控制该值。Hovering over any value in the Simulation tab provides a tooltip describing how to control that value.

“房间”选项卡Room tab

仿真器以模拟“房间”的空间映射网格形式模拟世界坐标输入。The emulator simulates world input in the form of the spatial mapping mesh from simulated rooms. 使用此选项卡可以选择要加载的房间而不是默认房间。This tab lets you pick the room to load instead of the default room.

HoloLens 仿真器的“房间”选项卡

有关详细信息,请参阅模拟的房间See simulated rooms for more information.

“帐户”选项卡Account tab

在“帐户”选项卡中,可将仿真器配置为使用 Microsoft 帐户登录。The Account tab allows you to configure the emulator to sign in with a Microsoft Account. 在测试需要用户使用帐户登录的 API 时,此配置非常有用。This is useful for testing APIs that require the user to be signed-in with an account. 选中此页上的框后,后续启动仿真器时,系统会要求你登录,如同用户首次启动 HoloLens 时那样。After checking the box on this page, later launches of the emulator will ask you to sign in, just like a user would the first time the HoloLens is started.

模拟的房间Simulated rooms

模拟的房间可用于在多个环境中测试应用程序。Simulated rooms are useful for testing your application in multiple environments. 仿真器随附了多个房间。Several rooms are shipped with the emulator. 安装仿真器后,可以在 %ProgramFiles(x86)%\Windows Kits\10\Microsoft XDE\(version)\Plugins\Rooms 中找到这些房间。Once you install the emulation, you'll find them in %ProgramFiles(x86)%\Windows Kits\10\Microsoft XDE\(version)\Plugins\Rooms. 所有这些房间是使用 HoloLens 在真实环境中捕获的:All of these rooms were captured in real environments using a HoloLens:

  • DefaultRoom.xef - 配有一台电视机、一个茶几和两套沙发的小客厅。DefaultRoom.xef - A small living room with a TV, coffee table, and two sofas. 启动仿真器时,默认会加载该房间。Loaded by default when you start the emulator.
  • Bedroom1.xef - 配有一张桌子的小卧室。Bedroom1.xef - A small bedroom with a desk.
  • Bedroom2.xef - 配有一张双人床、梳妆台、床头柜和步入式衣橱的卧室。Bedroom2.xef - A bedroom with a queen size bed, dresser, nightstands, and walk-in closet.
  • GreatRoom.xef - 配有客厅、餐桌和厨房的开阔大房间。GreatRoom.xef - A large open space great room with living room, dining table, and kitchen.
  • LivingRoom.xef - 配有壁炉、沙发、摇椅和摆放了花瓶的茶几的客厅。LivingRoom.xef - A living room with a fireplace, sofa, armchairs, and a coffee table with a vase.

也可以在 HoloLens(第 1 代)上使用 Windows 设备门户的“模拟”页录制你自己的房间,以便在仿真器中使用它们。You can also record your own rooms to use in the emulator with the Simulation page of the Windows Device Portal on your HoloLens (first gen).

在仿真器中,你只会看到自己渲染的全息影像。In the emulator, you'll only see holograms that you render. 但你会看到全息影像后面的模拟房间。But you'll see the simulated room behind the holograms. 而在实际的 HoloLens 中,你会同时看到两者的混合形式。This is in contrast to the actual HoloLens where you see both blended together. 若要在 HoloLens 仿真器中查看模拟的房间,需要更新应用程序,以便在场景中渲染空间映射网格。If you want to see the simulated room in the HoloLens Emulator, you need to update your application to render the spatial mapping mesh in the scene.

已知问题Known Issues

  • 卸载 HoloLens 2 仿真器时,硬盘映像 (Flash.vhdx) 可能会留在硬盘驱动器上的 Windows Kits\10\Emulation\HoloLens<build number> 文件夹中。When uninstalling the HoloLens 2 Emulator, the hard disk image (Flash.vhdx) may be left on your hard drive in the Windows Kits\10\Emulation\HoloLens<build number> folder. 删除此文件是安全的。It's safe to delete this file.
  • 硬件图形加速可能导致全息应用在一些带有 AMD 或 Intel 显卡的系统上崩溃。Hardware graphics acceleration may cause Holographic apps to crash on some systems with AMD or Intel graphics. 在仿真器的“工具”窗口中禁用硬件图形加速可以解决此问题。Disabling hardware graphics acceleration in the emulator Tools window works around this issue.
  • 自 2020 年 7 月起安装最新的 Windows 更新后,HoloLens 仿真器(第 1 代)中的硬件图形加速功能可能不再可用。After installing the latest Windows updates as of July 2020, hardware graphics acceleration in the HoloLens Emulator (first Gen) might no longer be available. 硬件图形加速所需的 RemoteFX 组件已被弃用,将在将来的 Windows 版本中删除。The RemoteFX component needed for hardware graphics acceleration has been deprecated and will be removed in a future Windows release. 若要重新启用硬件图形加速,请使用 Enable-VMRemoteFXPhysicalVideoAdapter PowerShell cmdletTo re-enable hardware graphics acceleration, use the Enable-VMRemoteFXPhysicalVideoAdapter PowerShell cmdlet. 有关其他信息,请参阅有关在 Windows 中弃用和删除 RemoteFX 支持的文档Refer to the documentation on the deprecation and removal of RemoteFX support in Windows for additional information.

疑难解答Troubleshooting

安装仿真器时,可能会出现错误消息,指出需要“Visual Studio 2015 Update 1 和 UWP 工具版本 1.2”。You may see an error message while installing the emulator, indicating that you need "Visual Studio 2015 Update 1 and UWP tools version 1.2". 出现此错误的三个可能原因如下:There are three possible causes of this error:

  • Visual Studio 的版本不够新(需要 Visual Studio 2019、Visual Studio 2017 或 Visual Studio 2015 Update 1 或更高版本)。You don't have a recent enough version of Visual Studio (Visual Studio 2019, Visual Studio 2017, or Visual Studio 2015 Update 1 or later). 若要纠正此问题,请安装最新版本的 Visual Studio。To correct this, install the latest release of Visual Studio.
  • 已安装最新版本的 Visual Studio,但未安装通用 Windows 平台 (UWP) 工具。You have a recent version of Visual Studio, but you don't have the Universal Windows Platform (UWP) tools installed. 这是 Visual Studio 的一项可选功能。This is an optional feature for Visual Studio. 对于 HoloLens(第 1 代),你需要适用于 Visual Studio 2015 或 Visual Studio 2017 的 UWP 工具。For HoloLens (first Gen), you'll need UWP Tools for Visual Studio 2015 or Visual Studio 2017.

此外,在 Windows 的非专业版/企业版/教育版 SKU 上安装仿真器,或者未启用 Hyper-V 功能时,也可能会看到错误。You may also see an error installing the emulator on a non-Pro/Enterprise/Education SKU of Windows or if you don't have Hyper-V feature enabled.

  • 有关完整的要求,请阅读前面的系统要求部分。Read the system requirements section above for a complete set of requirements.
  • 另请确保已在系统上启用 Hyper-V 功能。Also ensure that the Hyper-V feature has been enabled on your system.

如果安装成功完成,但未看到 HoloLens 仿真器作为一个部署和调试选项列出:If your installation completes successfully, but you don't see the HoloLens Emulator as an option for deployment and debugging:

  • Visual Studio 项目配置已设置为 x86(HoloLens 第 1 代)或者 x86 或 x64(HoloLens 2 仿真器)。Your Visual Studio project configuration is set to x86 (HoloLens first Gen), x86 or x64 (HoloLens 2 Emulator).
  • 如果使用 Visual Studio 2019,则项目配置中的平台工具集应设置为 v142。If using Visual Studio 2019, the Platform Toolset in your project configuration is set to v142.

如果安装成功完成,但尝试启动 HoloLens 仿真器时 Visual Studio 显示错误:If your installation completes successfully, but Visual Studio displays an error attempting to launch the HoloLens Emulator:

  • 以管理员身份运行 Visual StudioRun Visual Studio as Administrator
  • 如果曾经只安装过 Visual Studio 2019,请检查 HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots 中的“KitsRoot10”注册表值是否指向 32 位 Program Files 文件夹(例如“C:\Program Files (x86)\Windows Kits\10”)。If you've only ever had Visual Studio 2019 installed, verify that the registry value "KitsRoot10" at HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots points to your 32-bit Program Files folder (for example, "C:\Program Files (x86)\Windows Kits\10"). 如果不是,请卸载 HoloLens 仿真器,将该注册表值更改为你的 32 位 Program Files 文件夹,然后重新安装 HoloLens 仿真器。If it doesn't, uninstall the HoloLens Emulator, change the registry value to your 32-bit Program Files folder, then reinstall the HoloLens Emulator. 此问题在 Visual Studio 2019 16.0.3 中已得到解决。This issue is addressed in Visual Studio 2019 16.0.3.

如果启动时仿真器显示“无效的字节编码”错误对话框:If the emulator displays an "Invalid Byte Encoding" error dialog upon launch:

  • 请删除 %localappdata%\Microsoft\XDE\HCS 中的所有文件,然后重试。Delete all files in %localappdata%\Microsoft\XDE\HCS and try again.

如果 Visual Studio 中的调试目标列表为空(例如,“启动”是唯一选项),并且你已遵循上述所有故障排除步骤:If your debug target list in Visual Studio is empty (for example, Start is the only option) and you've followed all troubleshooting steps above:

  • 请删除 %localappdata%\Microsoft\VisualStudio\<安装 ID>\CoreCon 中的 ConfigurationCache 文件夹,然后重试。Delete the ConfigurationCache folder in %localappdata%\Microsoft\VisualStudio\<installation id>\CoreCon and try again.

如果仿真器启动时系统挂起,请对仿真器图形禁用硬件加速。If your system hangs when the emulator is starting, disable hardware acceleration for emulator graphics.

  • 在“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\XDE\10.0”中创建名为“DisableGPU”的注册表 DWORD 值,并将其值设置为 1。Create a registry DWORD value named "DisableGPU" at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\XDE\10.0 and set its value to 1.

下一个开发检查点Next Development Checkpoint

如果你遵循我们规划的 Unity 开发检查点历程,则你就处于部署阶段之中。If you're following the Unity development checkpoint journey we've laid out, you're in the midst of the deployment stage. 从这里,你可以继续了解下一个主题:From here, you can continue to the next topic:

或直接跳到添加高级服务:Or jump directly to adding advanced services:

你可以随时返回到 Unity 开发检查点You can always go back to the Unity development checkpoints at any time.

另请参阅See also