/// <summary> /// Connected is called whenever we set up a new server or client /// </summary> /// <param name="networker"></param> public void Connected(NetWorker networker, UnityEngine.UI.Text connectionText = null) { string info = "Networker is bound"; if (!networker.IsBound) { BMSLog.LogWarning("NetWorker failed to bind"); //return; } else { BMSLog.Log(info); if (connectionText != null) { connectionText.text = info; } } if (!haveNetworkManager) { BMSLog.LogWarning("Network Manager could not be found. This should never happen!"); if (networkManagerGO != null) { Destroy(networkManagerGO); } networkManager = GetNetworkManager(); networkManager.Initialize(networker); } info = "Networker Connection Complete"; BMSLog.Log(info); if (connectionText != null) { connectionText.text = info; } }
private Steamworks.Data.Lobby GetLobby() { if (lobby.Id.Value > 0) { return(lobby); } else { lobby = networkController.GetLobby(); if (lobby.Id.Value > 0) { return(lobby); } else { BMSLog.LogWarning("Could not find this lobby"); return(default);
private void Start() { var gC = FindObjectOfType <GameController>(); networkController = (NetworkController)gC.GetController(typeof(NetworkController)) as NetworkController; if (!networkController) { BMSLog.LogWarning("Could not find networkController - should not see me"); } // Init the MainThreadManager MainThreadManager.Create(); connectButton.enabled = false; serverListEntryTemplateHeight = ((RectTransform)serverListEntryTemplate.transform).rect.height; RefreshLobbiesAsync(); }
/// <summary> /// Finalize networker creation /// </summary> /// <param name="networker">The FacepunchP2PServer or FacepunchP2PClient just created</param> public void Connected(NetWorker networker) { if (!networker.IsBound) { BMSLog.LogWarning("NetWorker failed to bind"); return; } if (mgr == null && networkManager == null) { BMSLog.LogWarning("A network manager was not provided, generating a new one instead"); networkManager = new GameObject("Network Manager"); mgr = networkManager.AddComponent <NetworkManager>(); } else if (mgr == null) { mgr = Instantiate(networkManager).GetComponent <NetworkManager>(); } mgr.Initialize(networker); if (useInlineChat && networker.IsServer) { SceneManager.sceneLoaded += CreateInlineChat; } if (networker is IServer) { if (!dontChangeSceneOnConnect) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } else { NetworkObject.Flush(networker); } } }
private void Start() { var gC = FindObjectOfType <GameController>(); networkController = (NetworkController)gC.GetController(typeof(NetworkController)) as NetworkController; if (!networkController) { BMSLog.LogWarning("Could not find networkController - should not see me"); } // Init the MainThreadManager MainThreadManager.Create(); playButton.enabled = false; playerListEntryTemplateHeight = ((RectTransform)playerListEntryTemplate.transform).rect.height; RefreshPlayers(); SetLobbyEvents(); if (!networkController.GetIsHost()) { LoadedAsClient(); } GetLobby(); }