Esempio n. 1
0
 public static void ScheduleYieldTask(YieldTask task)
 {
     if (Instance != null)
     {
         Instance.StartCoroutine(WaitYieldInstruction(task.instruction, task.callback, task.state));
     }
     else
     {
         _yieldTasks.Add(task);
     }
 }
    public IEnumerator LoginAnonymously()
    {
        var task = new YieldTask <Firebase.Auth.FirebaseUser>(auth.SignInAnonymouslyAsync());

        yield return(task);

        if (task.Task.IsCanceled)
        {
            Debug.LogError("Sign in canceled");
            yield break;
        }

        if (task.Task.IsFaulted)
        {
            Debug.LogError("Error Signing in: " + task.Task.Exception);
            yield break;
        }

        var user = task.Task.Result;

        if (user == null)
        {
            Debug.LogError("Unknown error signing in!");
            yield break;
        }

        User = user;

        Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId);
        IsLoggedIn = true;
        LoggedIn.Invoke();

        LogsManager.SendLogDirectly(new Log(
                                        LogType.LoggedIn,
                                        null
                                        ));

        yield break;
    }
    public IEnumerator LoginWithEmailAndPassword(string email, string password, Action <bool> afterLoginAction)
    {
        Debug.Log("loggi");
        var task = new YieldTask <Firebase.Auth.FirebaseUser>(auth.SignInWithEmailAndPasswordAsync(email, password));

        yield return(task);

        bool success = false;

        if (task.Task.IsCanceled)
        {
            Debug.LogError("Sign in canceled");
        }

        else if (task.Task.IsFaulted)
        {
            Debug.LogError("Error Signing in: " + task.Task.Exception);
        }

        else
        {
            var user = task.Task.Result;
            if (user == null)
            {
                Debug.LogError("Unknown error signing in!");
            }
            else
            {
                User    = user;
                success = true;
                Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId);
            }
        }
        afterLoginAction(success);
        yield break;
    }