Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Firebase.Auth.FirebaseAuth auth;
- :
- // Use this for initialization
- void Start () {
- auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
- }
- :
- public void OnClickLoginButton()
- {
- Text usernameField = GameObject.Find("UserNameText").GetComponent<Text>();
- Text passwordField = GameObject.Find("PasswordText").GetComponent<Text>();
- string username = usernameField.text;
- string password = passwordField.text;
- auth.CreateUserWithEmailAndPasswordAsync(username, password).ContinueWith(task0 => {
- if (!task0.IsCanceled && !task0.IsFaulted){
- Debug.Log(string.Format("Created {0}", usernameField.text));
- auth.SignInWithEmailAndPasswordAsync(username, password).ContinueWith(task1 =>{
- if(!task1.IsFaulted && !task1.IsCanceled){
- Debug.Log(string.Format("Logined {0}", usernameField.text));
- Firebase.Auth.FirebaseUser user = auth.CurrentUser;
- if(user != null){
- Debug.Log(string.Format("UserName is {0}", user.Email));
- Debug.Log(string.Format("UserID is {0}", user.UserId));
- // ここにログイン完了時の処理を入れる
- }
- }
- });
- }
- else{
- Debug.Log(string.Format("Creation failed {0}", usernameField.text));
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement