public IEnumerator StartNetwork(bool bHost)
        {
            //start listening to other hosts
            NetworkDiscoveryCustom discovery = GetComponent <NetworkDiscoveryCustom>();

            discovery.Initialize();
            if (bHost)
            {
                discovery.StartAsServer();
                StartHost();
            }
            else
            {
                discovery.StartAsClient();

                while (discovery.running)
                {
                    yield return(new WaitForEndOfFrame());
                }
            }
        }
        /// <summary>
        /// Searches for other LAN games in the current network.
        /// </summary>
        public IEnumerator DiscoverNetwork()
        {
            //start listening to other hosts
            NetworkDiscoveryCustom discovery = GetComponent <NetworkDiscoveryCustom>();

            discovery.Initialize();
            discovery.StartAsClient();

            //wait few seconds for broadcasts to arrive
            yield return(new WaitForSeconds(8));

            //we haven't found a match, open our own
            if (discovery.running)
            {
                discovery.StopBroadcast();
                yield return(new WaitForSeconds(0.5f));

                discovery.StartAsServer();
                StartHost();
            }
        }
        public void StopNetwork()
        {
            NetworkDiscoveryCustom discovery = GetComponent <NetworkDiscoveryCustom>();

            discovery.StopBroadcast();
        }