You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity构建Hololens应用报错:UnityEngine.XR中不存在WindowsMR命名空间

HoloLens构建报错:UnityEngine.XR.WindowsMR不存在的解决建议

问题详情

正在开发HoloLens与Android间的多用户AR体验,安装了以下MRTK教程包:

  • MRTK.HoloLens2.Unity.Tutorials.Assets.MultiUserCapabilities.2.7.2.unitypackage
  • MRTK.HoloLens2.Unity.Tutorials.Assets.GettingStarted.2.7.2.unitypackage
  • MRTK.HoloLens2.Unity.Tutorials.Assets.AzureSpatialAnchors.2.7.2.unitypackage

Unity编辑器内运行正常,能显示“number of players in the experience: 1”提示,但构建HoloLens应用时触发错误:

Library\PackageCache\com.microsoft.azure.object-anchors.runtime@f40a6f902078-1669719345205\Runtime\Core\ObjectAnchorsWorldManager.cs(151,29): error CS0234: The type or namespace name 'WindowsMR' does not exist in the namespace 'UnityEngine.XR' (are you missing an assembly reference?)

已尝试重新导入XR Plug-in,使用Unity版本为2019.4.36f1。

可行解决方案

  1. 检查XR插件管理配置
    打开Edit > Project Settings > XR Plug-in Management,确保Windows Mixed Reality插件已启用,且在Universal Windows Platform(UWP)平台的插件列表中被勾选。2019.4版本需手动指定对应平台的XR插件,避免漏选UWP目标下的Windows MR组件。

  2. 修复Azure Object Anchors包兼容性
    当前使用的Azure Object Anchors运行时包版本可能与Unity 2019.4不兼容。尝试将该包更新至适配2019.4的稳定版本,或确认教程指定的包版本与你的Unity版本匹配。

  3. 重置项目缓存与程序集引用
    删除项目根目录下的Library文件夹,让Unity重新生成项目缓存与程序集引用,这能解决因缓存损坏导致的程序集缺失问题。

  4. 确认UWP构建目标配置
    切换到UWP构建目标(File > Build Settings > 选择Universal Windows Platform > Switch Platform),等待资源重新导入完成后再尝试构建。同时确保UWP的SDK版本选择与HoloLens设备兼容的最新Windows 10 SDK。

  5. 重新导入MRTK包并运行配置向导
    删除已导入的三个MRTK教程包,清理项目残留文件后重新导入。导入完成后运行MRTK配置向导(Mixed Reality Toolkit > Utilities > Configure Project for MRTK),让工具自动修复项目的XR与UWP相关配置。

内容的提问来源于stack exchange,提问作者ChocooPanda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 12:25:23