void Update()
 {
     if (valid == false && GameObject.Find("LocalNetworkManager") && GameObject.Find("LocalMultiplayer"))
     {
         valid = true;
         print("is Host : " + Globals.networkData.isHost + " | Connection State : " + Globals.networkData.ConnectionState);
         if (Globals.networkData.isHost == 1)
         {
             local.StartHosting();
             print("Started Hosting...");
         }
         else if (Globals.networkData.isHost == 0 && Globals.networkData.ConnectionState == 1)
         {
             local.StartJoining();
             print("Started Joining...");
         }
     }
 }
示例#2
0
 // Update is called once per frame
 void Update()
 {
     if (valid == false && GameObject.Find("LocalNetworkManager") && GameObject.Find("LocalMultiplayer"))
     {
         valid = true;
         print("is Host : " + Globals.networkData.isHost + " | Connection State : " + Globals.networkData.ConnectionState);
         if (Globals.networkData.isHost == 1)
         {
             local.StartHosting();
             //print("Started Hosting...");
         }
         else if (Globals.networkData.isHost == 0 && Globals.networkData.ConnectionState == 1)
         {
             local.StartJoining();
             //print("Started Joining...");
         }
     }
     if (local.IsConnected() && GameObject.Find("LocalNetworkManager") && GameObject.Find("LocalMultiplayer") && allow == true)
     {
         StartCoroutine(CheckWhereHostIs());
     }
 }
示例#3
0
    public void Awake()
    {
        if (GameObject.Find("btnCancel"))
        {
            btnCancel = GameObject.Find("btnCancel").GetComponent <Button>();
            btnCancel.onClick.AddListener(() =>
            {
                local.Cancel();
                ShowGUI = true;
            });
            btnCancel.gameObject.SetActive(false);
        }

        if (GameObject.Find("btnHost") && GameObject.Find("btnJoin"))
        {
            btnHost = GameObject.Find("btnHost").GetComponent <Button>();
            btnHost.onClick.AddListener(() =>
            {
                local.StartHosting();
                ShowGUI = false;
            });

            btnJoin = GameObject.Find("btnJoin").GetComponent <Button>();
            btnJoin.onClick.AddListener(() =>
            {
                local.StartJoining();
                ShowGUI = false;
            });

            btnHost.gameObject.SetActive(false);
        }


        local          = FindObjectOfType(typeof(LocalMultiplayer)) as LocalMultiplayer;
        networkManager = GetComponent <LocalNetworkManager>();
    }