修改base
This commit is contained in:
parent
fc5f538527
commit
078d33a649
@ -3,7 +3,7 @@ using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class JsonReadBase : MonoBehaviour
|
||||
public class JsonReadBase : Base
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用的JSON加载和解析方法
|
||||
|
62
base/base.cs
62
base/base.cs
@ -10,29 +10,31 @@ using UnityEngine.UI;
|
||||
|
||||
public class Base : MonoBehaviour
|
||||
{
|
||||
private List<string> LoadClassName = new List<string>() { "ImageLoader" , "Global", "gameGlobal" };//写入需要全局自动实例化的类
|
||||
[Header("关闭窗口的按钮")] public Button retbutton;
|
||||
[Header("需要关闭的窗口")] public GameObject ClosureObj;
|
||||
[HideInInspector]
|
||||
public string description = "";
|
||||
private List<string> LoadClassName = new List<string>() { "gameGlobal", "Mengyao_Skill_Date" };//写入需要全局自动实例化的类
|
||||
// [Header("关闭窗口的按钮")] public Button retbutton;
|
||||
// [Header("需要关闭的窗口")] public GameObject ClosureObj;
|
||||
public static GameObject GlobalObj;
|
||||
/// <summary>
|
||||
///初始化
|
||||
///初始化
|
||||
/// </summary>
|
||||
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));
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化全局类
|
||||
/// 初始化全局类
|
||||
/// </summary>
|
||||
private void initializeGlobal()
|
||||
{
|
||||
@ -46,12 +48,12 @@ public class Base : MonoBehaviour
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 用于通过类名字符串动态调用类和方法
|
||||
/// 用于通过类名字符串动态调用类和方法
|
||||
/// </summary>
|
||||
/// <param name="className"></param>
|
||||
public void CallClassByString(string className)
|
||||
{
|
||||
// 获取类的 Type 对象
|
||||
// 获取类的 Type 对象
|
||||
Type type = Type.GetType(className);
|
||||
|
||||
if (type != null)
|
||||
@ -65,29 +67,29 @@ public class Base : MonoBehaviour
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按钮动画,点击后会放大缩小
|
||||
/// 按钮动画,点击后会放大缩小
|
||||
/// </summary>
|
||||
/// <param name="button">实施目标对象</param>
|
||||
/// <param name="max">放大倍率</param>
|
||||
/// <param name="timemultiple">动画持续时间倍率</param>
|
||||
/// <param name="button">实施目标对象</param>
|
||||
/// <param name="max">放大倍率</param>
|
||||
/// <param name="timemultiple">动画持续时间倍率</param>
|
||||
/// <returns></returns>
|
||||
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<bool> tcs = new TaskCompletionSource<bool>();
|
||||
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(() => {
|
||||
// 动画播放完成后执行的代码
|
||||
// 动画播放完成后执行的代码
|
||||
tcs.SetResult(true);
|
||||
}); // 第二个动画
|
||||
}); // 第二个动画
|
||||
await tcs.Task;
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加通用上移弹窗
|
||||
/// 添加通用上移弹窗
|
||||
/// </summary>
|
||||
/// <param name="Details"></param>
|
||||
/// <param name="time"></param>
|
||||
public void addEventPopUp(string Details,float time = 5f)//添加弹窗
|
||||
public void addEventPopUp(string Details,float time = 5f)//添加弹窗
|
||||
{
|
||||
GameObject prefab = Resources.Load<GameObject>("base/EventPopUp");
|
||||
prefab.GetComponent<EventPopUp>().time = time;
|
||||
@ -97,7 +99,7 @@ public class Base : MonoBehaviour
|
||||
}
|
||||
//logoPanel.ServerResponse TestserverResponse;
|
||||
//protected Dictionary<string, string> 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<string, string>
|
||||
// {
|
||||
@ -123,24 +125,24 @@ public class Base : MonoBehaviour
|
||||
// testhead = new Dictionary<string, string>();
|
||||
//}
|
||||
/// <summary>
|
||||
/// 判读是否为小数,并且必须大于零
|
||||
/// 判读是否为小数,并且必须大于零
|
||||
/// </summary>
|
||||
/// <param name="text">判断的字符串</param>
|
||||
/// <param name="text">判断的字符串</param>
|
||||
/// <returns></returns>
|
||||
public bool IsGreaterThanZeroDecimal(string text)//判断必须为小数而且大于0
|
||||
public bool IsGreaterThanZeroDecimal(string text)//判断必须为小数而且大于0
|
||||
{
|
||||
// 使用正则表达式匹配大于0的小数
|
||||
// 使用正则表达式匹配大于0的小数
|
||||
string pattern = @"^(?!0(\.0+)?$)(\d+(\.\d+)?|\.\d+)$";
|
||||
Regex regex = new Regex(pattern);
|
||||
|
||||
return regex.IsMatch(text);
|
||||
}
|
||||
/// <summary>
|
||||
/// 点击后关闭界面
|
||||
/// 点击后关闭界面
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <param name="my_gameObject"></param>
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user