예제 #1
0
        protected override void Initialize()
        {
            signinView            = ViewsManager.GetView <SignInView>("SigninView");
            signupView            = ViewsManager.GetView <SignUpView>("SignupView");
            passwordResetView     = ViewsManager.GetView <PasswordResetView>("PasswordResetView");
            passwordResetCodeView = ViewsManager.GetView <PasswordResetCodeView>("PasswordResetCodeView");
            emailConfirmationView = ViewsManager.GetView <EmailConfirmationView>("EmailConfirmationView");

            MsfTimer.WaitForEndOfFrame(() =>
            {
                if (useDefaultCredentials && Application.isEditor)
                {
                    signinView.SetInputFieldsValues(defaultUsername, defaultPassword);
                    signupView.SetInputFieldsValues(defaultUsername, defaultEmail, defaultPassword);
                }

                if (IsConnected)
                {
                    Msf.Events.Invoke(EventKeys.hideLoadingInfo);
                    signinView.Show();
                }
                else
                {
                    Msf.Events.Invoke(EventKeys.showLoadingInfo, "Connecting to master server... Please wait!");
                }
            });
        }
예제 #2
0
        public void SignUp()
        {
            Msf.Events.Invoke(EventKeys.showLoadingInfo, "Signing up... Please wait!");

            MsfTimer.WaitForSeconds(1f, () =>
            {
                string username = signupView.Username;
                string email    = signupView.Email;
                string password = signupView.Password;

                var credentials = new Dictionary <string, string>
                {
                    { "username", username },
                    { "email", email },
                    { "password", password }
                };

                Msf.Client.Auth.SignUp(credentials, (isSuccessful, error) =>
                {
                    Msf.Events.Invoke(EventKeys.hideLoadingInfo);

                    if (isSuccessful)
                    {
                        signupView.Hide();
                        signinView.SetInputFieldsValues(username, password);
                        signinView.Show();

                        logger.Debug($"You have successfuly signed up. Now you may sign in");
                    }
                    else
                    {
                        outputMessage = $"An error occurred while signing up: {error}";
                        Msf.Events.Invoke(EventKeys.showOkDialogBox, new OkDialogBoxViewEventMessage(outputMessage, null));
                        logger.Error(outputMessage);
                    }
                });
            });
        }