I want to add an auto login/sign in ability into my game, so when the player quits the game or goes to main menu, the login panel is gone and the player is automatically logged in. Then, I want the player to be logged out and no longer automatically sign in when he presses the "sign out" button.
Here are some previews of my game:
I'm sure this code works like this, but I have low experience on firebase. Additionally, there is lack of documentation on it with Unity so I don't know what is wrong with this script.
void Awake()
{
//Check that all of the necessary dependencies for Firebase are present on the system
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
{
dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available)
{
//If they are avalible Initialize Firebase
InitializeFirebase();
}
else
{
Debug.LogError("Could not resolve all Firebase dependencies: " + dependencyStatus);
}
});
//singleton
if (instance != null)
{
Destroy(gameObject);
}
else
{
instance = this;
DontDestroyOnLoad(gameObject);
}
}
private void InitializeFirebase()
{
Debug.Log("Setting up Firebase Auth");
//Set the authentication instance object
if (auth != null)
{
_MainMenuUI.instance.loginPanel.SetActive(false);
}
else
{
auth = FirebaseAuth.DefaultInstance;
DBreference = FirebaseDatabase.DefaultInstance.RootReference;
}
}
playerprefs
, but why when I go to main menu loginpaneltrue
insteadfalse
, I mean I suppose to be cant login because I've login at first and haven't sign out yet. \$\endgroup\$