public void clickOnUpdateAvatar() { String nickname = this.nickname.text; FirebaseUser currentUser = UserLogged.getLoggedUser(); if (!string.IsNullOrEmpty(nickname)) { if (currentUser != null) { Firebase.Auth.UserProfile profile = new Firebase.Auth.UserProfile { DisplayName = nickname, }; currentUser.UpdateUserProfileAsync(profile).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("UpdateUserProfileAsync was canceled."); return; } if (task.IsFaulted) { infoMessage.faceColor = new Color32(255, 0, 0, 255); AggregateException ex = task.Exception as AggregateException; if (ex != null) { Firebase.FirebaseException fbEx = null; foreach (Exception e in ex.InnerExceptions) { fbEx = e as Firebase.FirebaseException; if (fbEx != null) { break; } } if (fbEx != null) { infoMessage.text = fbEx.Message; } } return; } infoMessage.faceColor = new Color32(0, 255, 0, 255); infoMessage.text = "User profile updated successfuly!"; GameObject gameObj = GameObject.Find("User"); DontDestroyOnLoad(gameObj); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); }); } } else { infoMessage.faceColor = new Color32(255, 0, 0, 255); infoMessage.text = "Please enter a nickname!"; } }
// Use this for initialization void Start() { user = UserLogged.getLoggedUser(); profileName.text = user.DisplayName; }