Example #1
0
 public void loadNetworkObject()
 {
     if (isClient)
     {
         GameObject go = NetworkManager.singleton.client.connection.playerControllers [0].gameObject;
         networkMaster = go.GetComponent <NetworkMaster> () as NetworkMaster;
         //networkMaster = (NetworkMaster)FindObjectOfType (typeof(NetworkMaster));
     }
 }
    bool TryToConnectToAvailableServer()
    {
        List <HostData> hosts = NetworkMaster.Instance.hosts;

        if (hosts != null)
        {
            foreach (HostData host in hosts)
            {
                if (NetworkMaster.IsServerAvailable(host))
                {
                    SetupGame(true);
                    NetworkMaster.Instance.ConnectToServer(host);
                    infoText.text = "Connected.\nWaiting for more players...";
                    UnityEngine.Debug.Log(infoText.text);
                    return(true);
                }
            }
        }
        return(false);
    }
Example #3
0
 private void Start()
 {
     DontDestroyOnLoad(this);
     netMast = gameObject.GetComponent<NetworkMaster>();
 }