question

Eian Knudsen avatar image
Eian Knudsen asked

Registering User In Unity Not Working?

I created a simple Register User UI in PlayFab, and I am recieving an error... I understand what the issue is, but I am new to PlayFabSDK so I am unsure how to approach this problem. I've watched many tutorials, and the program is very simple and understandable, however they don't seem to get this error. I will post my code and error below.

Code:

    public void onRegister(){
        var request = new RegisterPlayFabUserRequest {
            Email = emailInput.text,
            Password = passwordInput.text,
            RequireBothUsernameAndEmail = false
        };
        PlayFabClientAPI.RegisterPlayFabUser(request, OnRegisterSuccess, OnError);
    }

    void OnRegisterSuccess(RegisterPlayFabUserResult result){
        registerText.text = "Register Success";
    }

    void OnError(PlayFabError error){
        registerText.text = "Error!";
    }

Error:

IndexOutOfRangeException: Index was outside the bounds of the array.
unity3d
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

For clarification, the error

IndexOutOfRangeException: Index was outside the bounds of the array.

is a common C# error, we can't target the specific API error acording to it. Could you please use the following method to print the detailed API error on your console then post it for our reference?

  void OnError(PlayFabError error)
    {
        registerText.text = "Error!";
        Debug.Log(error.GenerateErrorReport());
    }

Besides, we test your code using testing email address and the testing password. It can work fine. So, the issue may not on your code, but on the format of your email address.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.