public UNetNetServerDriver() { _networkGameObject = new GameObject("_internalListenServer"); _internalNetwork = _networkGameObject.AddComponent <UnityNetworkObject>(); _internalNetwork.OnServerPacket += OnServerPacket; _internalNetwork.OnClientPacket += OnClientPacket; _internalNetwork.Init(true); // we launch the local server! _internalNetwork.LaunchListenServer(); Object.DontDestroyOnLoad(_networkGameObject); }
// ReSharper disable once InconsistentNaming public UNetNetClientDriver(string inIP) { _networkGameObject = new GameObject("_internalListenClient"); _internalNetwork = _networkGameObject.AddComponent <UnityNetworkObject>(); _internalNetwork.OnServerPacket += OnServerPacket; _internalNetwork.OnClientPacket += OnClientPacket; _internalNetwork.OnConnected += OnClientConnected; _internalNetwork.OnFailedConnection += OnFailedConnected; _internalNetwork.OnDisconnect += OnClientDisconnected; _internalNetwork.Init(false); // we launch the local server! _internalNetwork.ConnectToServer(inIP); Object.DontDestroyOnLoad(_networkGameObject); }