UWP和HoloLens Unet [命令] [英] UWP and HoloLens Unet [Command]

查看:103
本文介绍了UWP和HoloLens Unet [命令]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个不同的Unity项目,一个是HoloLens应用程序,另一个是桌面应用程序.我的目标是通过桌面应用程序在HoloLens应用程序中操作对象.目前,当HoloLens是主机,而台式机充当客户端时,我可以使用Unet.通过HoloLens进行操作并将其传输到桌面应用程序是可行的,但反之亦然.当它用作服务器时,我无法连接到桌面应用程序.我猜想这与物体在世界位置上的定位有关,但是我不确定.

有人建议HoloLens可以是服务器,并且客户端可以通过具有[Command]实现的方法将命令发送到服务器.我在桌面应用程序上添加了playerPrefab,这样它就可以被识别为可以使我发送这些命令的播放器.不幸的是,这似乎不起作用.这将导致以下错误消息:找不到1的生成场景对象".将预制件添加到场景中并将其作为播放器拖到NetworkManager上,但这会导致对象不是真正的播放器(使我无法向服务器发送命令).

我确实找到了另一种方法:将权限授予非玩家对象.我尝试这样做,如下所示:

  1. 在HoloLens上启动服务器
  2. 连接到桌面应用程序
  3. 调用Rpc方法分配客户端权限

不幸的是,这导致了不同的错误消息:在Liver(UnityEngine.GameObject)上找不到传入[-1367249836]的接收者,服务器和客户端应该具有相同的NetworkBehaviour实例[netId = 1]"

我基本上想要实现的是拥有一个非玩家对象(因为桌面应用程序仅用于操纵HoloLens中的对象),因此能够对服务器上的对象(HoloLens)进行更改.

解决方案

我同意以上评论,即应在同一项目中进行开发.我们在工作中成功创建了一个远程支持应用程序,该应用程序允许桌面用户与HoloLens用户进行交互.我们通过在一个Unity项目中开发两个场景来实现这一点.

  1. 桌面场景
  2. HoloLens场景

这样做,我们能够使用相同的脚本来使应用程序在所有设备上都能正常工作. (我们必须添加一些if语句以使某些代码设备特定于此).对于桌面部分,3D场景的构建没有问题.

I have two different Unity projects, one is a HoloLens application and the other is the desktop application. My goal is to manipulate an object in the HoloLens application through the desktop application. At the moment I have Unet working when the HoloLens is the host and the desktop acting as the client. Manipulating through the HoloLens and transferring that to the desktop application works, but it doesn't vice versa. I am unable to connect to the desktop application when it serves as the server. I am guessing this has something to do with the anchoring of objects in world position, but I am not sure.

Someone else suggested that the HoloLens could be the server and that the client could send commands to the server through methods with the [Command] implementation. I added a playerPrefab on the desktop application so that it would be recognized as a player which would enable me to send those commands. Unfortunately, this doesn't seem to work. This results in the following error message: "Spawn scene object not found for 1". Adding the prefab to the scene and dragging it on the NetworkManager as a player, but that results in an object that isn't an actual player(disabling me from sending commands to the server).

I did find a different approach: granting authority to the non-player object. I tried to do this as follows:

  1. Start the server on the HoloLens
  2. Connect to the desktop application
  3. Invoke an Rpc-method to assign client authority

This, unfortunately, results in a different error message: "Found no receiver for incoming [-1367249836] on Liver(UnityEngine.GameObject), the server and client should have the same NetworkBehaviour instances[netId=1]"

What I basically want to achieve is to have a non-player object(since the desktop application is purely used to manipulate the object in the HoloLens) be able to make changes to the object on the server(HoloLens).

解决方案

I agree with the above comment that it should be developed in the same project. We successfully created an remote support application at work that allowed a desktop user to interact with a HoloLens user. We accomplished this by developing two scenes inside one Unity project.

  1. Desktop scene
  2. HoloLens scene

By doing so, we were able to draw on the same scripts to make the application work across all devices. (We had to throw in some if statements to make some of the code device specific). For the desktop part, 3D scene had no problems building.

这篇关于UWP和HoloLens Unet [命令]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆