using UnityEngine; using UnityEngine.SceneManagement; using Firebase.Auth; using System.Threading.Tasks; using UnityEditor; namespace BulletHellTemplate { /// /// This script handles logging out from Firebase, clearing PlayerPrefs, and returning to the login scene. /// public class LogOut : MonoBehaviour { [Header("Scene to load after logout")] public string loginScene; // SceneAsset reference to the login scene private FirebaseAuth auth; private void Start() { // Initialize Firebase Auth auth = FirebaseAuth.DefaultInstance; } /// /// Logs out the player from Firebase, clears PlayerPrefs, and loads the login scene. /// public async void PerformLogOut() { // Perform Firebase logout await LogOutFromFirebase(); // Clear PlayerPrefs data PlayerPrefs.DeleteAll(); PlayerPrefs.Save(); Debug.Log("PlayerPrefs cleared. Logging out..."); // Load the login scene if (loginScene != null) { SceneManager.LoadScene(loginScene); } else { Debug.LogError("Login scene reference is not set."); } } /// /// Logs out the current user from Firebase asynchronously. /// private async Task LogOutFromFirebase() { if (auth.CurrentUser != null) { // Sign out from Firebase auth.SignOut(); Debug.Log("User signed out from Firebase."); } else { Debug.LogWarning("No user is logged in to Firebase."); } // Simulating waiting for any asynchronous operations, if needed await Task.Delay(100); // Just a small delay to ensure smooth logout process } } }