study/first_study/Library/PackageCache/com.unity.collections@aea9d3bd5e19/Unity.Collections.Editor/CLILeakDetectionSwitcher.cs
jh04010421 739d49f1a0 Unity | 2026.01.20
수업 실습 파일
2026-01-20 11:01:57 +09:00

33 lines
1.2 KiB
C#

using System;
using UnityEditor;
using Unity.Collections;
using UnityEngine;
class CLILeakDetectionSwitcher
{
[InitializeOnLoadMethod]
static void SetLeakDetectionModeFromEnvironment()
{
var nativeLeakDetectionMode = Environment.GetEnvironmentVariable("UNITY_JOBS_NATIVE_LEAK_DETECTION_MODE");
if (!string.IsNullOrEmpty(nativeLeakDetectionMode))
{
switch (nativeLeakDetectionMode)
{
case "0":
NativeLeakDetection.Mode = NativeLeakDetectionMode.Disabled;
break;
case "1":
NativeLeakDetection.Mode = NativeLeakDetectionMode.Enabled;
break;
case "2":
NativeLeakDetection.Mode = NativeLeakDetectionMode.EnabledWithStackTrace;
break;
default:
Debug.LogWarning("The environment variable UNITY_JOBS_NATIVE_LEAK_DETECTION_MODE has an invalid value. Please use: 0 = Disabled, 1 = Enabled, 2 = EnabledWithStackTrace.");
break;
}
Debug.Log("Native leak detection mode: " + NativeLeakDetection.Mode);
}
}
}