using UnityEngine; using UnityEngine.UI; using System; public class AccountDisplay : MonoBehaviour { [Header("UI 元件")] public Text UIDText; public Text NameText; public Text TypeText; public Text CreateTimeText; public Text EmailText; public Text EmailVerifiedText; public Text PhoneText; public Text PhoneVerifiedText; void Start() { ShowAccountInfo(); } public void ShowAccountInfo() { int uid = PlayerPrefs.GetInt("UID", 0); string name = PlayerPrefs.GetString("Name", ""); string type = PlayerPrefs.GetString("Type", ""); string createTime = PlayerPrefs.GetString("CreateTime", ""); string email = PlayerPrefs.GetString("Email", ""); bool emailVerified = PlayerPrefs.GetInt("EmailVerified", 0) == 1; string phone = PlayerPrefs.GetString("Phone", ""); bool phoneVerified = PlayerPrefs.GetInt("PhoneVerified", 0) == 1; string uidHex; if (uid != 0 && !string.IsNullOrEmpty(type)) { char typeChar = type switch { "R" => '0', "A" => 'a', "B" => 'b', "D" => 'f', _ => '?' }; string uidHexPart = uid.ToString("X8"); uidHex = $"{typeChar}x{uidHexPart}"; } else { uidHex = "0x00000000"; } string typeDisplay = type; switch (typeDisplay) { case "R": typeDisplay = "玩家"; break; case "A": typeDisplay = "Alpha 測試"; break; case "B": typeDisplay = "Beta 測試"; break; case "D": typeDisplay = "開發者"; break; } // Email string emailDisplay = ""; if (!string.IsNullOrEmpty(email) && email.Contains("@")) { int atIndex = email.IndexOf('@'); string prefix = email.Substring(0, Math.Min(2, atIndex)); string domain = email.Substring(atIndex); emailDisplay = prefix + "*****" + domain; } // Phone string phoneDisplay = ""; if (!string.IsNullOrEmpty(phone) && phone.Length >= 3) { string last3 = phone.Substring(phone.Length - 3); phoneDisplay = new string('*', phone.Length - 3) + last3; } // Verified string emailVerText = emailVerified ? "已驗證" : "未驗證"; string phoneVerText = phoneVerified ? "已驗證" : "未驗證"; // UI UIDText.text = "使用者號碼: " + uidHex; NameText.text = "顯示名稱: " + name; TypeText.text = "帳號類型: " + typeDisplay; CreateTimeText.text = "創建日期: " + createTime; EmailText.text = "電子信箱: " + emailDisplay; EmailVerifiedText.text = "狀態: " + emailVerText; PhoneText.text = "電話號碼: " + phoneDisplay; PhoneVerifiedText.text = "狀態: " + phoneVerText; } }