0

I am relatively new to Unity and am currently trying to build an multi-user app on Hololens. Currently, I am just trying to get two Hololens to connect over LAN using Unet. When I use one of my Hololens to host the server, my laptop can connect to it during play mode in the Unity editor. However, when I try to use my other Hololens to connect to it, it does not work and I am not sure why. Does anyone else have this problem? And if so, how do you fix it?

Thanks in advance.

Edit: some code

Here's the code for network manager

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
using System;

public class NetworkManager_Custom : NetworkManager
{

    public void StartupHost()
    {
        setPort();
        NetworkManager.singleton.StartHost();
    }

    public void JoinGame()
    {
        SetIpAddress();
        setPort();
        NetworkManager.singleton.StartClient();
    }

    private void SetIpAddress()
    {
        string Address = "192.168.2.80";
        NetworkManager.singleton.networkAddress = Address;
    }

    private void setPort()
    {
        NetworkManager.singleton.networkPort = 9001;
    }
} 

Here's the code for the start-server button

using HoloToolkit.Unity.InputModule;
using UnityEngine;
using UnityEngine.Networking;

public class ok : NetworkBehaviour, IFocusable, IInputClickHandler
{
    bool hasFocus;
    public NetworkManager_Custom manager;

    
    public void OnFocusEnter()
    {
        hasFocus = true;
    }

    public void OnFocusExit()
    {
        hasFocus = false;
    }

    public void OnInputClicked(InputClickedEventData eventData)
    {
        
        manager.StartupHost();
        
    }
}

Here's the code for joining server as client

using HoloToolkit.Unity.InputModule;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.NetworkSystem;

public class aegf : NetworkBehaviour, IFocusable, IInputClickHandler
{
    bool hasFocus;
    public NetworkManager_Custom manager;

    

    public void OnFocusEnter()
    {
        hasFocus = true;
    }

    public void OnFocusExit()
    {
        hasFocus = false;
    }

    public void OnInputClicked(InputClickedEventData eventData)
    {
       
        manager.JoinGame();
    }
}
  • The issue may be caused by various different reasons. You need to troubleshoot the network connectivity issue between your two HoloLens first, and it would be better if you add some code to illustrate the issue. – Hernando - MSFT Jul 21 '20 at 07:24
  • Besides, UNet is deprecated and will be removed from Unity in the future, so it is not a recommended technology for now:[UNet Deprecation FAQ](https://support.unity3d.com/hc/en-us/articles/360001252086-UNet-Deprecation-FAQ). As a result, PUN is a better choice for creating a shared experience on HoloLens, and Microsoft has released a step-by-step tutorial about how to create a PUN app:[Setting up Photon Unity Networking](https://learn.microsoft.com/en-us/windows/mixed-reality/mr-learning-sharing-02) – Hernando - MSFT Jul 21 '20 at 07:24
  • Thanks for the reply, I added the code I used. I will try out PUN for now, though the guide seems like it is used for Hololens2, and I am using Hololens1. – Jonathan Linathan Jul 21 '20 at 16:33

1 Answers1

0

It's worth double-checking the capabilties that you've set. Ensure all three of these are selected:

  • InternetClient
  • InternetClientServer
  • PrivateNetworkClientServer

Ref: https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/appxmanifestschema/element-capability

PJB
  • 13
  • 3