_xiaofang/xiaofang/Assets/Script/loginScripts/AccountManager.cs
2025-01-02 16:27:21 +08:00

24 lines
568 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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如果没有保存过的账号名
}
}