From 078d33a64976cff5d00632045cd1f826250526c8 Mon Sep 17 00:00:00 2001 From: wulongxiao <2545507770@qq.com> Date: Wed, 8 Jan 2025 13:03:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9base?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JsonRead/JsonReadBase.cs | 2 +- base/base.cs | 62 +++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/JsonRead/JsonReadBase.cs b/JsonRead/JsonReadBase.cs index 79945c8..6c778be 100644 --- a/JsonRead/JsonReadBase.cs +++ b/JsonRead/JsonReadBase.cs @@ -3,7 +3,7 @@ using UnityEngine; using System.IO; using System.Collections.Generic; -public class JsonReadBase : MonoBehaviour +public class JsonReadBase : Base { /// /// 通用的JSON加载和解析方法 diff --git a/base/base.cs b/base/base.cs index 4dfb66a..38e1b18 100644 --- a/base/base.cs +++ b/base/base.cs @@ -10,29 +10,31 @@ using UnityEngine.UI; public class Base : MonoBehaviour { - private List LoadClassName = new List() { "ImageLoader" , "Global", "gameGlobal" };//写入需要全局自动实例化的类 - [Header("关闭窗口的按钮")] public Button retbutton; - [Header("需要关闭的窗口")] public GameObject ClosureObj; + [HideInInspector] + public string description = ""; + private List LoadClassName = new List() { "gameGlobal", "Mengyao_Skill_Date" };//鍐欏叆闇瑕佸叏灞鑷姩瀹炰緥鍖栫殑绫 +// [Header("鍏抽棴绐楀彛鐨勬寜閽")] public Button retbutton; +// [Header("闇瑕佸叧闂殑绐楀彛")] public GameObject ClosureObj; public static GameObject GlobalObj; /// - ///初始化 + ///鍒濆鍖 /// private void Awake() { if (Application.isPlaying) { - Application.targetFrameRate = Mathf.RoundToInt(55f); // 设置目标帧率 + Application.targetFrameRate = Mathf.RoundToInt(55f); // 璁剧疆鐩爣甯х巼 initializeGlobal(); - if (retbutton != null) - { - retbutton.onClick.AddListener(() => CancelOnClick(retbutton, ClosureObj)); - } + // if (retbutton != null) + // { + // retbutton.onClick.AddListener(() => CancelOnClick(retbutton, ClosureObj)); + // } } } /// - /// 初始化全局类 + /// 鍒濆鍖栧叏灞绫 /// private void initializeGlobal() { @@ -46,12 +48,12 @@ public class Base : MonoBehaviour } } /// - /// 用于通过类名字符串动态调用类和方法 + /// 鐢ㄤ簬閫氳繃绫诲悕瀛楃涓插姩鎬佽皟鐢ㄧ被鍜屾柟娉 /// /// public void CallClassByString(string className) { - // 获取类的 Type 对象 + // 鑾峰彇绫荤殑 Type 瀵硅薄 Type type = Type.GetType(className); if (type != null) @@ -65,29 +67,29 @@ public class Base : MonoBehaviour } /// - /// 按钮动画,点击后会放大缩小 + /// 鎸夐挳鍔ㄧ敾,鐐瑰嚮鍚庝細鏀惧ぇ缂╁皬 /// - /// 实施目标对象 - /// 放大倍率 - /// 动画持续时间倍率 + /// 瀹炴柦鐩爣瀵硅薄 + /// 鏀惧ぇ鍊嶇巼 + /// 鍔ㄧ敾鎸佺画鏃堕棿鍊嶇巼 /// - public async Task ButtonClickAnimationAsync(GameObject button,float max=1.25f,float timemultiple = 1)//按钮动画 + public async Task ButtonClickAnimationAsync(GameObject button,float max=1.25f,float timemultiple = 1)//鎸夐挳鍔ㄧ敾 { TaskCompletionSource tcs = new TaskCompletionSource(); Sequence mySequence = DOTween.Sequence(); - mySequence.Append(button.transform.DOScale(max, 0.1f* timemultiple)) // 第一个动画 + mySequence.Append(button.transform.DOScale(max, 0.1f* timemultiple)) // 绗竴涓姩鐢 .Append(button.transform.DOScale(1f, 0.2f* timemultiple)).OnComplete(() => { - // 动画播放完成后执行的代码 + // 鍔ㄧ敾鎾斁瀹屾垚鍚庢墽琛岀殑浠g爜 tcs.SetResult(true); - }); // 第二个动画 + }); // 绗簩涓姩鐢 await tcs.Task; } /// - /// 添加通用上移弹窗 + /// 娣诲姞閫氱敤涓婄Щ寮圭獥 /// /// /// - public void addEventPopUp(string Details,float time = 5f)//添加弹窗 + public void addEventPopUp(string Details,float time = 5f)//娣诲姞寮圭獥 { GameObject prefab = Resources.Load("base/EventPopUp"); prefab.GetComponent().time = time; @@ -97,7 +99,7 @@ public class Base : MonoBehaviour } //logoPanel.ServerResponse TestserverResponse; //protected Dictionary testhead; - //public async void testLogo()//测试登录 + //public async void testLogo()//娴嬭瘯鐧诲綍 //{ // LoginAndGetToken.loginbody body = new LoginAndGetToken.loginbody @@ -111,7 +113,7 @@ public class Base : MonoBehaviour // if (response != null && response.code == 200 && response.data != null) // { // TestserverResponse = response; - // addEventPopUp("测试登录成功"); + // addEventPopUp("娴嬭瘯鐧诲綍鎴愬姛"); // testhead = new Dictionary // { @@ -123,24 +125,24 @@ public class Base : MonoBehaviour // testhead = new Dictionary(); //} /// - /// 判读是否为小数,并且必须大于零 + /// 鍒よ鏄惁涓哄皬鏁帮紝骞朵笖蹇呴』澶т簬闆 /// - /// 判断的字符串 + /// 鍒ゆ柇鐨勫瓧绗︿覆 /// - public bool IsGreaterThanZeroDecimal(string text)//判断必须为小数而且大于0 + public bool IsGreaterThanZeroDecimal(string text)//鍒ゆ柇蹇呴』涓哄皬鏁拌屼笖澶т簬0 { - // 使用正则表达式匹配大于0的小数 + // 浣跨敤姝e垯琛ㄨ揪寮忓尮閰嶅ぇ浜0鐨勫皬鏁 string pattern = @"^(?!0(\.0+)?$)(\d+(\.\d+)?|\.\d+)$"; Regex regex = new Regex(pattern); return regex.IsMatch(text); } /// - /// 点击后关闭界面 + /// 鐐瑰嚮鍚庡叧闂晫闈 /// /// /// - public async void CancelOnClick(Button button,GameObject my_gameObject = null)//取消按钮 + public async void CancelOnClick(Button button,GameObject my_gameObject = null)//鍙栨秷鎸夐挳 { await ButtonClickAnimationAsync(button.gameObject); if (my_gameObject != null)