问题
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:
- Start the server on the HoloLens
- Connect to the desktop application
- 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).
回答1:
I agree with the above comment that she 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.
- Desktop scene
- 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.
来源:https://stackoverflow.com/questions/49575706/uwp-and-hololens-unet-command