using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class AccountManager : MonoBehaviour { private const string AccountKey = "LastLoggedAccount"; // 保存账号名 public static void SaveLastLoggedAccount(string accountName) { PlayerPrefs.SetString(AccountKey, accountName); PlayerPrefs.Save(); } // 获取上次登录的账号名 public static string GetLastLoggedAccount() { return PlayerPrefs.GetString(AccountKey, null); // 默认值为 null,如果没有保存过的账号名 } }