Merge branch 'NewMaster' into LouDi_Quan

This commit is contained in:
shenjianxing 2025-04-23 11:46:59 +08:00
commit 614c726a7c
3 changed files with 41 additions and 4 deletions

View File

@ -52,6 +52,29 @@ public class FixedMainEditor
AssetDatabase.Refresh();
}
[MenuItem("Tools/生成Timer文件")]
private static void GeneratorTimer()
{
if (File.Exists(Application.dataPath + "/TimerLock.asset"))
{
string path = "Assets/TimerLock.asset";
var asset = AssetDatabase.LoadAssetAtPath<TimerLock>(path);
if (asset != null)
{
if (string.IsNullOrEmpty(asset.time) == false)
{
//第一次获取获取系统时间
DateTime currentDateTime = DateTime.Now;
string RecordData = currentDateTime.ToString("yyyy-MM-dd HH:mm:ss");
string strMerge = asset.time + "|" + RecordData;
EncryptFileCreator.EncryptAndSaveData(strMerge, "Timer.txt");
}
}
}
//刷新界面
AssetDatabase.Refresh();
}

View File

@ -7,10 +7,20 @@ using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;
public class VirtualFPostProcess : IPostprocessBuildWithReport
public class VirtualFPostProcess : IPostprocessBuildWithReport, IPreprocessBuildWithReport
{
public int callbackOrder => 0;
/// <summary>
/// 构建前生成时间锁
/// </summary>
/// <param name="report"></param>
public void OnPreprocessBuild(BuildReport report)
{
// 生成时间锁
GneratorTimerLock();
}
public void OnPostprocessBuild(BuildReport report)
{
string projectPath = Application.dataPath;
@ -29,9 +39,7 @@ public class VirtualFPostProcess : IPostprocessBuildWithReport
Debug.LogWarning("未找到数据目录: " + dataFolderPath);
}
DeletAssetBundle(buildOutputPath);
// 生成时间锁
GneratorTimerLock();
AssetDatabase.Refresh();
}
/// <summary>
@ -173,4 +181,6 @@ public class VirtualFPostProcess : IPostprocessBuildWithReport
}
return new string(chars);
}
}

View File

@ -27,6 +27,7 @@ public class DateManager : MonoBehaviour
public void ShowTip(string str)
{
gameObject.SetActive(true);
ui.SetActive(true);
text.text = str;
}
@ -42,6 +43,7 @@ public class DateManager : MonoBehaviour
if (string.IsNullOrEmpty(datas))
{
updateTimer?.Invoke();
return;
}
EndTimer = datas.Split('|')[0];
RecordData = datas.Split('|')[1];
@ -70,12 +72,14 @@ public class DateManager : MonoBehaviour
{
Debug.LogError($"数据出错: {e.Message}");
error?.Invoke($"数据出错: {e.Message}");
return;
}
if (JudgeExpire())
{
Debug.Log("请联系管理员进行升级");
timeOut?.Invoke("请联系管理员进行升级");
return;
}
}