示例#1
0
    public async void ClickRegister()
    {
        _mHandler    = GameObject.FindObjectOfType <MenuHandler>();
        _aConnection = GameObject.FindObjectOfType <AccountConnection>();

        InputField codeInputField = null;
        InputField nameInputField = null;

        var test = GameObject.FindObjectsOfType <InputField>();

        foreach (InputField x in test)
        {
            switch (x.name)
            {
            case nameof(EInputFieldNames.NewUsernameInputField):
                nameInputField = x;
                break;

            case nameof(EInputFieldNames.NewPasswordInputField):
                codeInputField = x;
                break;
            }
        }

        try
        {
            _username = nameInputField.text;
            _passcode = codeInputField.text;
        }
        catch (NullReferenceException)
        {
            throw new NullReferenceException("ClickRegister: Use of unassigned InputField.");
        }

        //Now that we have the input field info, we can toggle off the reg canvas
        _mHandler.ToggleCanvas(_mHandler.GetRegistrationCanvas());

        Task <BoolStringResult> createAccountTask = _aConnection.CreateAccountAsync(_username, _passcode);
        var result = await createAccountTask;

        _mHandler.UpdateConfirmationMessageText(result._stringMessage + " Registration", result._successful);

        if (result._successful)
        {
            _mHandler.SetPrevCanvas(_mHandler.GetLoginCanvas());
        }

        _mHandler.ToggleCanvas(_mHandler.GetLoadingCanvas());
        _mHandler.ToggleCanvas(_mHandler.GetMessageCanvas());
    }