UnityEngine.Networking.NetworkManager.StopServer C# (CSharp) Method

StopServer() public method

Stops the server that the manager is using.

public StopServer ( ) : void
return void
        public void StopServer()
        {
            if (NetworkServer.active)
            {
                this.OnStopServer();
                if (LogFilter.logDebug)
                {
                    Debug.Log("NetworkManager StopServer");
                }
                this.isNetworkActive = false;
                NetworkServer.Shutdown();
                this.StopMatchMaker();
                if (this.m_OfflineScene != "")
                {
                    this.ServerChangeScene(this.m_OfflineScene);
                }
                this.CleanupNetworkIdentities();
            }
        }

Usage Example

コード例 #1
0
 void Update()
 {
     if (!showGUI)
     {
         return;
     }
     if (!manager.IsClientConnected() && !NetworkServer.active && manager.matchMaker == null)
     {
         if (UnityEngine.Application.platform != RuntimePlatform.WebGLPlayer)
         {
             if (Input.GetKeyDown(KeyCode.S))
             {
                 destroyStuff();
                 manager.StartServer();
             }
             if (Input.GetKeyDown(KeyCode.H))
             {
                 destroyStuff();
                 manager.StartHost();
             }
         }
         if (Input.GetKeyDown(KeyCode.C))
         {
             destroyStuff();
             manager.StartClient();
         }
     }
     if (NetworkServer.active)
     {
         if (manager.IsClientConnected())
         {
             if (Input.GetKeyDown(KeyCode.X))
             {
                 manager.StopHost();
             }
         }
         else
         {
             if (Input.GetKeyDown(KeyCode.X))
             {
                 manager.StopServer();
             }
         }
     }
 }
All Usage Examples Of UnityEngine.Networking.NetworkManager::StopServer