using System; using System.Collections.Generic; using System.Data; using TMPro; using UnityEngine; using UnityEngine.UI; public class Main : MonoBehaviour{ public void 截圖(){ string fileName = string.Format("{0}/screenshot_{1}.png", Application.persistentDataPath, System.DateTime.Now.ToString("yyyyMMdd_HHmmss")); ScreenCapture.CaptureScreenshot(fileName); } public static void 清除控件(GameObject content){ List childList = new List(); foreach (Transform child in content.transform) { childList.Add(child.gameObject); } foreach (GameObject child in childList) { if (child.name.Contains("(Clone)")) { Destroy(child); } } } public static void 載入表格(string table_name,DataTable table,Transform tableParent,GameObject rowPrefab,GameObject ceneter,TMP_FontAsset myFont,Sprite UIsprite,GameObject LinePrefab,bool overflowMode){ 清除控件(ceneter); ceneter.GetComponent().sizeDelta = new Vector2(ceneter.GetComponent().sizeDelta.x,table.Rows.Count*70f); Image centerImage = ceneter.GetComponent(); if (centerImage == null){ centerImage = ceneter.AddComponent(); centerImage.type = Image.Type.Sliced; } centerImage.sprite = UIsprite; centerImage.fillCenter = false; centerImage.color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f); float[] width = {220f,448.72f}; //==========動態生成表格================================== // 取得所有欄位名稱,並建立表頭 for (int i = 0; i < table.Rows.Count; i++){ // 建立資料列 GameObject row = Instantiate(rowPrefab, tableParent); // 設定資料列位置 row.GetComponent().anchoredPosition = new Vector2(0, -70 * i); // 建立資料列中的所有欄位 for (int j = 0; j < table.Columns.Count; j++){ // 取得欄位值 string value = table.Rows[i][j].ToString(); GameObject cellText = new(table_name+"_Cells_"+i.ToString()+"_"+j.ToString()); cellText.transform.SetParent(row.transform, false); cellText.AddComponent().text = value; cellText.GetComponent().tag="Cells"; if(overflowMode){cellText.GetComponent().overflowMode=TextOverflowModes.Ellipsis;} cellText.GetComponent().anchorMin = new Vector2(0, 1); cellText.GetComponent().anchorMax = new Vector2(0, 1); cellText.GetComponent().pivot = new Vector2(0, 1); if(j==0){ cellText.GetComponent().sizeDelta=new Vector2(width[0],70f); cellText.GetComponent().anchoredPosition = new Vector2(0,0); }else if(j==1){ cellText.GetComponent().sizeDelta=new Vector2(width[1],70f); cellText.GetComponent().anchoredPosition = new Vector2(225f,0); }else{ cellText.GetComponent().sizeDelta=new Vector2(width[0],70f); cellText.GetComponent().anchoredPosition = new Vector2(678.72f,0); } } } TextMeshProUGUI[] texts = ceneter.GetComponentsInChildren(); foreach (TextMeshProUGUI text in texts){ if(text.tag.Contains("Cells")){ text.font = myFont; text.color = Main.Global.系統主題 == 1 ? new Color(0, 0, 0, 1) : text.color; text.alignment = TextAlignmentOptions.Center; text.fontStyle = FontStyles.Bold; text.fontSize=28; /*text.enableAutoSizing = true; text.autoSizeTextContainer = true;*/ text.margin = new Vector4(10, 0, 10, 0); } } for (int j = 0; j < table.Columns.Count-1; j++){ GameObject Separation = Instantiate(LinePrefab, tableParent); Separation.GetComponent().sizeDelta = new Vector2(5f,ceneter.GetComponent().sizeDelta.y-5f); Separation.GetComponent().anchorMin = new Vector2(0, 1); Separation.GetComponent().anchorMax = new Vector2(0, 1); Separation.GetComponent().pivot = new Vector2(0, 1); Separation.GetComponent().color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f); if(j==0){ Separation.GetComponent().anchoredPosition = new Vector2(220f,0); }else{ Separation.GetComponent().anchoredPosition = new Vector2(673.72f,0); } } } public static class Global { public static int 系統主題=1; public static string 版本號比對,螢幕方向,螢幕格式,排行榜難度="一般",一般最高="0",困難最高="0",地獄最高="0",夢魘最高="0",關卡難度="一般",使用者UID="",使用者金幣="",使用者鑽石="", 使用者道具1="",使用者道具2="",使用者道具3="",使用者現金道具1="",使用者ID="",使用者暱稱="",系統語言="中文"; public static bool 已載入現金道具表=false,刷新金幣=false,刷新訂閱時間=false,失去焦點=false,刷新現金道具=false,刷新現金道具2=false; public static float rate, rate_, 固高, 固寬, 固比, 固比1,登出條件,登入條件; public static string PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PA1, PA2, PA3, PA4, PA5, PA6, PA9, PA20; public static DataTable 道具清單_tabel,菟幣道具清單_tabel; public static string[,] PHP = new string[5,2]; public static List 中文姓 = new(){ "趙", "錢", "孫", "李", "周", "吳", "鄭", "王", "馮", "陳", "褚", "衛", "蔣", "沈", "韓", "楊", "朱", "秦", "尤", "許", "何", "呂", "施", "張", "孔", "曹", "嚴", "華", "金", "魏", "陶", "姜", "戚", "謝", "鄒", "喻", "柏", "水", "竇", "章", "雲", "蘇", "潘", "葛", "奚", "範", "彭", "郎", "魯", "韋", "昌", "馬", "苗", "鳳", "花", "方", "俞", "任", "袁", "柳", "酆", "鮑", "史", "唐", "費", "廉", "岑", "薛", "雷", "賀", "倪", "湯", "滕", "殷", "羅", "畢", "郝", "鄔", "安", "常", "樂", "於", "時", "傅", "皮", "卞", "齊", "康", "伍", "余", "元", "卜", "顧", "孟", "平", "黃", "和", "穆", "蕭", "尹", "姚", "邵", "湛", "汪", "祁", "毛", "禹", "狄", "米", "貝", "明", "臧", "計", "伏", "成", "戴", "談", "宋", "茅", "龐", "熊", "紀", "舒", "屈", "項", "祝", "董", "梁", "杜", "阮", "藍", "閔", "席", "季", "麻", "強", "賈", "路", "婁", "危", "江", "童", "顏", "郭", "梅", "盛", "林", "刁", "鍾", "徐", "丘", "駱", "高", "夏", "蔡", "田", "樊", "胡", "凌", "霍", "虞", "萬", "支", "柯", "昝", "管", "盧", "莫", "經", "房", "裘", "繆", "干", "解", "應", "宗", "丁", "宣", "賁", "鄧", "郁", "單", "杭", "洪", "包", "諸", "左", "石", "崔", "吉", "鈕", "龔", "程", "嵇", "邢", "滑", "裴", "陸", "榮", "翁", "荀", "羊", "於", "惠", "甄", "曲", "家", "封", "芮", "羿", "儲", "靳", "汲", "邴", "糜", "松", "井", "段", "富", "巫", "烏", "焦", "巴", "弓", "牧", "隗", "山", "谷", "車", "侯", "宓", "蓬", "全", "郗", "班", "仰", "秋", "仲", "伊", "宮", "甯", "仇", "欒", "暴", "甘", "鈄", "曆", "戎", "祖", "武", "符", "劉", "景", "詹", "束", "龍", "葉", "幸", "司", "韶", "郜", "黎", "薊", "溥", "印", "宿", "白", "懷", "蒲", "邰", "從", "鄂", "索", "咸", "籍", "賴", "卓", "藺", "屠", "蒙", "池", "喬", "陰", "欽", "歸", "海", "岳", "帥", "緱", "亢", "況", "後", "有", "琴", "商", "牟", "佘", "佴", "伯", "賞", "墨", "哈", "譙", "笪", "年", "愛", "陽", "佟", "習", "夏侯", "諸葛", "聞人", "東方", "赫連", "皇甫", "尉遲", "公羊", "澹臺", "公冶", "宗政", "濮陽", "淳於", "單於", "太叔", "申屠", "公孫", "仲孫", "軒轅", "令狐", "鍾離", "宇文", "長孫", "慕容", "鮮於", "閭丘", "司徒", "司空", "亓官", "司寇", "仉督", "子車", "顓孫", "端木", "巫馬", "公西", "漆雕", "樂正", "壤駟", "公良", "拓拔", "夾谷", "宰父", "谷梁", "晉楚", "闕丘", "澹台", "王孫", "司馬", "上官", "歐陽" }; public static List 中文名 = new(){ "偉", "芳", "明", "潔", "艷", "華", "玲", "軍", "英", "濤", "萍", "強", "娜", "杰", "娟", "剛", "平", "燕", "輝", "靜", "敏", "波", "斌", "欣", "峰", "霞", "麗", "亮", "琴", "宇", "龍", "彬", "琳", "芬", "虹", "勇", "青", "雯", "楊", "莎", "瑞", "洪", "旭", "曉", "毅", "婷", "君", "兵", "瑩", "博", "奇", "慧", "嬌", "彤", "丹", "坤", "立", "爽", "俊", "淑", "宏", "愛", "豪", "楠", "樂", "冬", "若", "萌", "琦", "琳", "碩", "晨", "豪", "嵐", "逸", "飛", "虹", "霖", "哲", "昊", "文", "偉", "雄", "曉", "楠", "俊", "博", "卓", "皓", "然", "逸", "恆", "凱", "康", "飛", "寧", "維", "啟", "捷", "熙", "卓", "琛", "峰", "元", "強", "洋", "玉", "飛", "濤", "楓", "輝", "劍", "超", "新", "炎", "曦", "濤", "鵬", "寧", "程", "翔", "浩", "曉", "宇", "龍", "斌", "毅", "鵬", "華", "剛", "強", "偉", "濤", "杰", "彬", "波", "兵", "宇", "勇", "青", "峰", "博", "浩", "強", "剛", "文", "濤", "志", "磊", "勇", "彬", "曉", "洪", "鵬", "偉", "華", "軍", "剛", "燕", "靜", "敏", "萍", "磊", "艷", "霞", "琳", "虹", "勇", "青", "雯", "楊", "莎", "瑞", "洪", "旭", "曉", "毅", "婷", "君", "兵", "瑩", "博", "奇", "慧", "嬌", "彤", "丹", "坤", "立", "爽", "尼" }; } }