I made a script with the PlayFab API that checks if a username is available. My approach seems really dirty to me, So I'm wondering if there is a better way.
And how can I set this up so that CheckUser() returns a bool?
public static void CheckUser(string username)
{
string password = GameFunctions.RandomString (16); //generates a 16 digit random string
LoginWithPlayFabRequest request = new LoginWithPlayFabRequest ()
{
Username = username,
Password = password,
};
PlayFabClientAPI.LoginWithPlayFab (request, OnCheckUserStub, OnCheckUser);
}
static void OnCheckUserStub(LoginResult result)
{
//this method is a placeholder and should never be called
}
static void OnCheckUser(PlayFabError error)
{
if (error.ToString().Contains ("AccountNotFound"))
{
Debug.Log ("available");
} else
{
Debug.Log ("taken");
}
}