HoloLens多用户协同(共享场景和操作)


目标:实现多台HoloLens看同一虚拟物体处于物理空间的同一位置。
实现该目标的方法有很多,本文介绍的是基于 Photon Unity Networkiing插件的方法和基于 Azure Spatial Anchors的方法,实现多用户协同。

基于Photon Unity Networkiing插件

环境和版本

Unity 2019.4.12f1
MRTK v2.4.0
Azure Spatial Anchors SDK Core 2.8.1
Azure Spatial Anchors SDK for Windows 2.8.1
MRTK.HoloLens2.Unity.Tutorials.Assets.GettingStarted.2.4.0.unitypackage
MRTK.HoloLens2.Unity.Tutorials.Assets.AzureSpatialAnchors.2.4.0.unitypackage
MRTK.HoloLens2.Unity.Tutorials.Assets.MultiUserCapabilities.2.4.0.unitypackage

环境搭建

这里笔者默认已经完成了前两步,即Unity 2019.4.12f1,MRTK v2.4.0;没有完成的参考官方文档:Initializing your project and deploying your first application

Azure Spatial Anchors SDK安装

下载MixedRealityFeatureTool,根据官方教程进行配置,选配如下:
在这里插入图片描述

MRTK.HoloLens2.Unity.Tutorials.Assets

笔者将这三个版本的包打包上传了:https://download.csdn.net/download/qq_41452267/23521081

设置 Photon Unity Networking

设置 Photon Unity Networking
如果导入Photon后出现错误Assets\MRTK.Tutorials.MultiUserCapabilities\Scripts\OwnershipHandler.cs(10,55): error CS0535: 'OwnershipHandler' does not implement interface member 'IPunOwnershipCallbacks.OnOwnershipTransferFailed(PhotonView, Player)',直接把继承出错的类删除即可,这是因为:
OnOwnershipTansferFailed was recently added in v2.29 - 15. March 2021 (see version history).
The Microsoft HoloLens guide was made before that.
Simply implement the interface to fix the error (add empty method with that signature).
具体见链接:https://forum.photonengine.com/discussion/18509/error-cs0535-occurred-while-following-the-steps-of-mrtk-tutorial-in-ms-docs-hololens-2

场景搭建

https://docs.microsoft.com/zh-cn/windows/mixed-reality/develop/unity/tutorials/mr-learning-sharing-03

基于Azure Spatial Anchors

环境搭建

基于Azure Spatial Anchors与基于Photon Unity Networkiing插件的方法所用的Unity、MRTK、ASA版本均相同,不同的是,需要额外安装插件MRTK.HoloLens2.Unity.Tutorials.Assets.AzureSpatialAnchors.LegacyWSA.2.5.3.unitypackage
在这里插入图片描述

场景搭建

将多台HL之间共享的虚拟物体设置为Anchor,该方法需要 Create a Spatial Anchors resource,具体步骤见:
Getting started with Azure Spatial Anchors

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 16
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值