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

StopHost() public method

This stops both the client and the server that the manager is using.

public StopHost ( ) : void
return void
        public void StopHost()
        {
            bool active = NetworkServer.active;
            this.OnStopHost();
            this.StopServer();
            this.StopClient();
            if ((this.m_MigrationManager != null) && active)
            {
                this.m_MigrationManager.LostHostOnHost();
            }
        }

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))
                    {
                        manager.StartServer();
                    }
                    if (Input.GetKeyDown(KeyCode.H))
                    {
                        manager.StartHost();
                    }
                }
                if (Input.GetKeyDown(KeyCode.C))
                {
                    manager.StartClient();
                }
            }
            if (NetworkServer.active && manager.IsClientConnected())
            {
                if (Input.GetKeyDown(KeyCode.X))
                {
                    manager.StopHost();
                }
            }
        }
All Usage Examples Of UnityEngine.Networking.NetworkManager::StopHost