From 9d4daa4fc017e16762619073941b8c1f33d660fd Mon Sep 17 00:00:00 2001 From: Ding Yuntian <1491671119@qq.com> Date: Tue, 11 Mar 2025 20:50:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Framework/LogKit/LogKit.cs | 2 +- Assets/Scripts/Game Loop/GameLoopManager.cs | 22 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Framework/LogKit/LogKit.cs b/Assets/Scripts/Framework/LogKit/LogKit.cs index 2fb63c542..49ee792c6 100644 --- a/Assets/Scripts/Framework/LogKit/LogKit.cs +++ b/Assets/Scripts/Framework/LogKit/LogKit.cs @@ -24,7 +24,7 @@ namespace AibisDream.Kit /// /// 每一行的打印内容 /// - private static string LogContent => "--------------------------" + Time + "--------------------------\n{0}\n{1}"; + private static string LogContent => Time + ": {0}\n{1}"; private FileLogger _fileLogger; diff --git a/Assets/Scripts/Game Loop/GameLoopManager.cs b/Assets/Scripts/Game Loop/GameLoopManager.cs index b5b958650..3cbe33878 100644 --- a/Assets/Scripts/Game Loop/GameLoopManager.cs +++ b/Assets/Scripts/Game Loop/GameLoopManager.cs @@ -2,6 +2,8 @@ using System; using System.Collections; using System.Collections.Generic; using System.Globalization; +using System.IO; +using System.Linq; using AibisDream.FixSystem; using AibisDream.Framework; using AibisDream.Kit; @@ -14,6 +16,8 @@ namespace AibisDream { public class GameLoopManager : Singleton { + private const int MaxSaveNum = 200; + #region 运行模式相关 [Header("可用so合集")] public TalkSceneSO[] totalSceneSos; @@ -229,6 +233,9 @@ namespace AibisDream // 存为Json JsonUtil.SaveJObject(saveFile, GetSavePath()); +#if !UNITY_EDITOR + DeleteOldSave(); +#endif } private string GetSavePath() @@ -245,9 +252,22 @@ namespace AibisDream gameStageStr = gameStage; } - return $"{SaveFilePath}/{_currentTalkSceneSo.name}_{gameStageStr}_{DateTime.Now:yyyyMMdd_HHmmss}"; + return $"{SaveFilePath}/{DateTime.Now:yyyyMMdd_HHmmss}_{_currentTalkSceneSo.name}_{gameStageStr}"; } + private void DeleteOldSave() + { + var fileList = Directory.GetFiles(SaveFilePath); + if (fileList.Length > MaxSaveNum) + { + var sorted = fileList.OrderByDescending(f => f).ToArray(); + for (var i = MaxSaveNum; i < fileList.Length; i++) + { + File.Delete(sorted[i]); + } + } + } + #endregion }