28 lines
781 B
C#
28 lines
781 B
C#
|
|
using UnityEngine;
|
||
|
|
using UnityEditor;
|
||
|
|
using System.IO;
|
||
|
|
|
||
|
|
public class SaveDataCleaner : EditorWindow
|
||
|
|
{
|
||
|
|
[MenuItem("Tools/Clear Save Data")]
|
||
|
|
public static void ClearSaveData()
|
||
|
|
{
|
||
|
|
string savePath = Path.Combine(Application.persistentDataPath, "savegame.json");
|
||
|
|
|
||
|
|
if (File.Exists(savePath))
|
||
|
|
{
|
||
|
|
File.Delete(savePath);
|
||
|
|
Debug.Log($"[SaveDataCleaner] 已删除存档文件: {savePath}");
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
Debug.LogWarning("[SaveDataCleaner] 未找到存档文件,无需清理。");
|
||
|
|
}
|
||
|
|
|
||
|
|
// 还可以清理 PlayerPrefs (如果有用到)
|
||
|
|
// PlayerPrefs.DeleteAll();
|
||
|
|
// Debug.Log("[SaveDataCleaner] 已清理 PlayerPrefs。");
|
||
|
|
|
||
|
|
AssetDatabase.Refresh();
|
||
|
|
}
|
||
|
|
}
|