在注册

时间:2015-12-06 15:02:27

标签: c# parse-platform unity3d

***我找出了导致错误的原因,这是因为我在SignUpAsync中调用了error.message.text,

我希望我能在这里获得一些帮助,只需要一次简单的登录,就可以在这2天了。

我已注册工作,但如果我再次使用相同的用户名,它将无法正常工作,但它不会返回任何错误或任何与我合作的事情并提醒用户...

我在文档中使用它

//try and register user and catch any errors.
            try
            {
                Task signUpTask = user.SignUpAsync().ContinueWith(t => {
                    if (t.IsFaulted)
                    {
                        // Errors from Parse Cloud and network interactions
                        using (IEnumerator<System.Exception> enumerator = t.Exception.InnerExceptions.GetEnumerator())
                        {
                            if (enumerator.MoveNext())
                            {
                                ParseException error = (ParseException)enumerator.Current;
                                ErrorMessage.text = error.Message;
                                Invoke("ClearForm", 4);

                                // error.Message will contain an error message
                                // error.Code will return "OtherCause"
                            }
                        }
                    }
                    else
                    {
                        ErrorMessage.color = Color.green;
                        ErrorMessage.text = "Login Success";
                    }
                });
            }
            catch (InvalidOperationException e)
            {
                ErrorMessage.color = Color.red;

                ErrorMessage.text = e.Message;
                Invoke("ClearForm", 4);

                // Error from the SDK logic checks
                // e.Message will contain the specific error
                // ex: "Cannot sign up user with an empty name."
            }

由于我在这两天失败了,我决定只在每次输入字段更新时创建一个检查用户名的函数,但即使这样也不起作用......而且它们只有一个小小的例子如何查询用户...它真的需要一些示例文档..请...

这是我试过的。

public void CheckUserName()
{
    if (UserNameInput.text.Length > 2)
    {

        ParseUser.Query.WhereEqualTo("username", UserNameInput.text).FindAsync().ContinueWith(t =>
        {
            if (t.Result.Any())
            {
                //it found someone make error symbol
                UserNameInputError.sprite = ErrorSprite;
                UserNameInputError.enabled = true;
                ErrorMessage.color = Color.red;
                ErrorMessage.text = "UserName Taken";

            }
            else
            {
                //it didnt? make success symbol
                UserNameInputError.sprite = SuccessSprite;
                UserNameInputError.enabled = true;
                ErrorMessage.color = Color.green;
                ErrorMessage.text = "UserName Availible";
            }

        });
    }
    else
    {

        UserNameInputError.sprite = ErrorSprite;
        UserNameInputError.enabled = true;
        ErrorMessage.color = Color.red;
        ErrorMessage.text = "Username Must be More Than 2 Characters";
    }

}

然而,这似乎不起作用,我得不到解析的反馈..只有2个错误在控制台可能是相关的?

错误是:

get_isActiveAndEnabled can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

set_enabled can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

我希望有人可以提供帮助..请为我提供一个如何检查用户名的示例?

如何在上面的signuptask中捕获登录错误?

以及如何将电子邮件存储在我从成功的Facebook登录获得的parseuser中。

非常感谢..

1 个答案:

答案 0 :(得分:0)

解决了它。我在异步中调用了统一方法。实现了我不需要,因为我可以检测parseuser.currentuser是否为空以打印我的成功消息。

相关问题