//Load the network manager on enable protected virtual void OnEnable() { if (_netManager == null) { _netManager = MPNetworkManager.singleton.gameObject.GetComponent <MPNetworkManager>(); } }
void Start() { _networkManager = MPNetworkManager.singleton.gameObject.GetComponent <MPNetworkManager>(); if (_quitButton != null) { _quitButton.SetActive(true); } else { Debug.LogError("Missing quitButton from MainMenuUI"); } //Used to return to correct page on return to menu switch (ReturnPage) { case MenuPage.Home: default: ShowDefaultPanel(); break; case MenuPage.Lobby: ShowLobbyPanel(); break; case MenuPage.SinglePlayer: ShowSingleplayerPanel(); break; } }
protected virtual void OnEnable() { if (_networkManager == null) { _networkManager = MPNetworkManager.singleton.gameObject.GetComponent <MPNetworkManager>(); } if (_menuUI == null) { _menuUI = MainMenuUI.Instance; } //Reset pages _currentPage = 0; _previousPage = 0; ClearUi(); //Disable NO SERVER FOUND error message _noServerFound.SetActive(false); _nextRefreshTime = Time.time; //Subscribe to network events if (_networkManager != null) { _networkManager.clientDisconnected += OnDisconnect; _networkManager.clientError += OnError; _networkManager.serverError += OnError; _networkManager.matchDropped += OnDrop; } }
//Subscribe to events on start protected virtual void Start() { _netManager = MPNetworkManager.singleton.gameObject.GetComponent <MPNetworkManager>(); if (_netManager != null) { _netManager.playerJoined += PlayerJoined; _netManager.playerLeft += PlayerLeft; _netManager.serverPlayersReadied += PlayersReadied; } }
public void Init(MPNetworkPlayer player) { Debug.LogFormat("Initializing lobby player - Ready {0}", player.Ready); this._mpNetworkPlayer = player; if (player != null) { player.SyncVarsChanged += OnNetworkPlayerSyncvarChanged; } _netManager = MPNetworkManager.singleton.gameObject.GetComponent <MPNetworkManager>(); //TanksNetworkManager.s_Instance; if (_netManager != null) { _netManager.playerJoined += PlayerJoined; _netManager.playerLeft += PlayerLeft; } _readyLabel.gameObject.SetActive(false); _waitingLabel.gameObject.SetActive(false); _readyButton.gameObject.SetActive(true); _readyButton.interactable = _netManager.hasSufficientPlayers; if (_netManager.gameType == NetworkGameType.SinglePlayer) { return; } MainMenuUI mainMenu = MainMenuUI.Instance; mainMenu.playerList.AddPlayer(this); mainMenu.playerList.DisplayDirectServerWarning(player.isServer && _netManager.matchMaker == null); if (player.hasAuthority) { SetupLocalPlayer(); } else { SetupRemotePlayer(); } UpdateValues(); }
protected virtual void Start() { _menuUi = MainMenuUI.Instance; _netManager = MPNetworkManager.singleton.gameObject.GetComponent <MPNetworkManager>(); }
protected virtual void OnEnable() { //Get fresh references to controllers _netManager = MPNetworkManager.singleton.gameObject.GetComponent <MPNetworkManager>(); _menuUi = MainMenuUI.Instance; }