Files
plugin-library/Assets/00.StaryEvo/Editor/Tools/LeakDetectionMode.cs

58 lines
1.8 KiB
C#
Raw Normal View History

2025-05-30 14:50:46 +08:00
using Unity.Collections;
using UnityEditor;
namespace Stary.Evo.Editor
{
/// <summary>
/// 内存泄露检测模式
/// </summary>
public class LeakDetectionMode
{
2025-05-30 17:00:07 +08:00
[MenuItem("Evo/内存泄漏检测/显示当前模式")]
2025-05-30 14:50:46 +08:00
static void ShowLeakDetection()
{
string message = string.Format("当前模式: {0}", NativeLeakDetection.Mode.ToString());
EditorUtility.DisplayDialog("内存泄漏检测模式", message, "OK");
}
2025-05-30 17:00:07 +08:00
[MenuItem("Evo/内存泄漏检测/禁用")]
2025-05-30 14:50:46 +08:00
static void LeakDetectionDisable()
{
NativeLeakDetection.Mode = NativeLeakDetectionMode.Disabled;
}
// 验证方法会在正式方法前执行,通不过就会置灰
2025-05-30 17:00:07 +08:00
[MenuItem("Evo/内存泄漏检测/禁用", true)]
2025-05-30 14:50:46 +08:00
static bool ValidateLeakDetectionDisable()
{
return NativeLeakDetection.Mode != NativeLeakDetectionMode.Disabled;
}
2025-05-30 17:00:07 +08:00
[MenuItem("Evo/内存泄漏检测/启用")]
2025-05-30 14:50:46 +08:00
static void LeakDetectionEnabled()
{
NativeLeakDetection.Mode = NativeLeakDetectionMode.Enabled;
}
2025-05-30 17:00:07 +08:00
[MenuItem("Evo/内存泄漏检测/启用", true)]
2025-05-30 14:50:46 +08:00
static bool ValidateLeakDetectionEnabled()
{
return NativeLeakDetection.Mode != NativeLeakDetectionMode.Enabled;
}
2025-05-30 17:00:07 +08:00
[MenuItem("Evo/内存泄漏检测/启用堆栈跟踪")]
2025-05-30 14:50:46 +08:00
static void LeakDetectionEnabledWithStackTrace()
{
NativeLeakDetection.Mode = NativeLeakDetectionMode.EnabledWithStackTrace;
}
2025-05-30 17:00:07 +08:00
[MenuItem("Evo/内存泄漏检测/启用堆栈跟踪", true)]
2025-05-30 14:50:46 +08:00
static bool ValidateLeakDetectionEnabledWithStackTrace()
{
return NativeLeakDetection.Mode != NativeLeakDetectionMode.EnabledWithStackTrace;
}
}
}