Example #1
0
    void Update()
    {
        // only update while visible
        if (!panel.activeSelf)
        {
            return;
        }

        // status
        statusText.text = manager.IsConnecting() ? "Connecting..." : "";

        // buttons
        registerButton.onClick.SetListener(() => { FindObjectOfType <UIPopup>().Show(registerMessage); });
        loginButton.interactable = !manager.IsConnecting();
        loginButton.onClick.SetListener(() => { manager.StartClient(); });
        hostButton.interactable = !manager.IsConnecting();
        hostButton.onClick.SetListener(() => { manager.StartHost(); });
        cancelButton.gameObject.SetActive(manager.IsConnecting());
        cancelButton.onClick.SetListener(() => { manager.StopClient(); });
        dedicatedButton.onClick.SetListener(() => { manager.StartServer(); });
        dedicatedButton.interactable = !manager.IsConnecting();
        quitButton.onClick.SetListener(() => { Application.Quit(); });

        // inputs
        manager.id = accountInput.text;
        manager.pw = passwordInput.text;

        // copy servers to dropdown; copy selected one to networkmanager ip/port.
        serverDropdown.interactable = !manager.IsConnecting();
        serverDropdown.options      = manager.serverList.Select(
            sv => new Dropdown.OptionData(sv.name)
            ).ToList();
        manager.networkAddress = manager.serverList[serverDropdown.value].ip;
    }
Example #2
0
    // LOGIN MASK //////////////////////////////////////////////////////////////
    void UpdateLoginMask()
    {
        // only update if visible
        if (!loginPanel.activeSelf)
        {
            return;
        }

        // status
        loginStatus.text = manager.IsConnecting() ? "Connecting..." : "";

        // button login
        btnLogin.interactable = !manager.IsConnecting();
        btnLogin.onClick.SetListener(() => { manager.StartClient(); });

        // button host
        btnHost.interactable = !manager.IsConnecting();
        btnHost.onClick.SetListener(() => { manager.StartHost(); });

        // button dedicated
        btnDedicated.interactable = !manager.IsConnecting();
        btnDedicated.onClick.SetListener(() => { manager.StartServer(); });

        // inputs
        manager.id = inputName.text;
        manager.pw = inputPass.text;
    }
        void Update()
        {
            if (manager == null)
            {
                manager = NetworkManager.singleton as NetworkManagerMMO;
            }

            // only show while offline
            // AND while in handshake since we don't want to show nothing while
            // trying to login and waiting for the server's response
            if (manager.state == NetworkState.Offline || manager.state == NetworkState.Handshake)
            {
                panel.SetActive(true);

                // status
                if (manager.IsConnecting())
                {
                    statusText.text = "Connecting...";
                }
                else if (manager.state == NetworkState.Handshake)
                {
                    statusText.text = "Handshake...";
                }
                else
                {
                    statusText.text = "";
                }

                // buttons. interactable while network is not active
                // (using IsConnecting is slightly delayed and would allow multiple clicks)
                registerButton.interactable = !manager.isNetworkActive;
                registerButton.onClick.SetListener(() => { uiPopup.Show(registerMessage); });
                loginButton.interactable = !manager.isNetworkActive && manager.IsAllowedAccountName(accountInput.text);
                loginButton.onClick.SetListener(() => { manager.StartClient(); });
                hostButton.interactable = Application.platform != RuntimePlatform.WebGLPlayer && !manager.isNetworkActive && manager.IsAllowedAccountName(accountInput.text);
                hostButton.onClick.SetListener(() => { manager.StartHost(); });
                cancelButton.gameObject.SetActive(manager.IsConnecting());
                cancelButton.onClick.SetListener(() => { manager.StopClient(); });
                dedicatedButton.interactable = Application.platform != RuntimePlatform.WebGLPlayer && !manager.isNetworkActive;
                dedicatedButton.onClick.SetListener(() => { manager.StartServer(); });
                quitButton.onClick.SetListener(() => { NetworkManagerMMO.Quit(); });

                // inputs
                manager.loginAccount  = accountInput.text;
                manager.loginPassword = passwordInput.text;

                // copy servers to dropdown; copy selected one to networkmanager ip/port.
                serverDropdown.interactable = !manager.isNetworkActive;
                serverDropdown.options      = manager.serverList.Select(
                    sv => new Dropdown.OptionData(sv.name)
                    ).ToList();
                manager.networkAddress = manager.serverList[serverDropdown.value].ip;
            }
            else
            {
                panel.SetActive(false);
            }
        }
Example #4
0
    void Awake()
    {
        // NetworkManager.singleton is null for some reason
        manager = FindObjectOfType <NetworkManagerMMO>();

        // button onclicks
        btnQuit.onClick.SetListener(() => { Application.Quit(); });
        btnLogin.onClick.SetListener(() => { manager.StartClient(); });
        btnRegister.onClick.SetListener(() => { FindObjectOfType <UIPopup>().Show(registerMessage); });
        btnHost.onClick.SetListener(() => { manager.StartHost(); });
        btnCancel.onClick.SetListener(() => { manager.StopClient(); });
        btnDedicated.onClick.SetListener(() => { manager.StartServer(); });
    }
Example #5
0
    void Update()
    {
        // only show while offline or trying to connect
        if (!manager.IsClientConnected())
        {
            panel.SetActive(true);

            // status
            statusText.text = manager.IsConnecting() ? "Connecting..." : "";

            // buttons. interactable while network is not active
            // (using IsConnecting is slightly delayed and would allow multiple clicks)
            registerButton.onClick.SetListener(() => { uiPopup.Show(registerMessage); });
            loginButton.interactable = !manager.isNetworkActive && manager.IsAllowedAccountName(accountInput.text);
            loginButton.onClick.SetListener(() => { manager.StartClient(); });
            hostButton.interactable = !manager.isNetworkActive && manager.IsAllowedAccountName(accountInput.text);
            hostButton.onClick.SetListener(() => { manager.StartHost(); });
            cancelButton.gameObject.SetActive(manager.IsConnecting());
            cancelButton.onClick.SetListener(() => { manager.StopClient(); });
            dedicatedButton.interactable = !manager.isNetworkActive;
            dedicatedButton.onClick.SetListener(() => { manager.StartServer(); });
            quitButton.onClick.SetListener(() => { NetworkManagerMMO.Quit(); });

            // inputs
            manager.loginAccount  = accountInput.text;
            manager.loginPassword = passwordInput.text;

            // copy servers to dropdown; copy selected one to networkmanager ip/port.
            serverDropdown.interactable = !manager.isNetworkActive;
            serverDropdown.options      = manager.serverList.Select(
                sv => new Dropdown.OptionData(sv.name)
                ).ToList();
            manager.networkAddress = manager.serverList[serverDropdown.value].ip;

            // addon system hooks
            Utils.InvokeMany(typeof(UILogin), this, "Update_");
        }
        else
        {
            panel.SetActive(false);
        }
    }