NoaUnloadAssetsCallbacks
Configure events related to asset unloading executed by NOA Debugger.
By passing a class that inherits NoaUnloadAssetsCallbacks to NoaProfiler, you can customize events related to asset unloading.
Overridable Members
Methods
| Name | Description |
|---|---|
| OnBeforeUnloadAssets() | Executed before the asset unloading process. |
| OnAfterUnloadAssets() | Executed after the asset unloading process. Executed even if NOA Debugger’s asset unloading process was not executed. |
Properties
| Name | Description |
|---|---|
| IsAllowBaseUnloadAssets | Determines whether to execute NOA Debugger’s asset unloading process. Default is true; if set to false, the asset unloading process is not executed. |
Related Types
INoaUnloadAssetsCallbacks
The overridable methods and properties of NoaUnloadAssetsCallbacks are defined in this interface.
If you want to consolidate multiple callback definitions in a custom class, or add callback functionality while inheriting an existing custom class, you can achieve this by using this interface instead of the NoaUnloadAssetsCallbacks class.
Sample Code
#if NOA_DEBUGGER
using NoaDebugger;
using System;
using UnityEngine;
// Example of executing events before and after NOA Debugger’s asset unloading process.
public class ExampleAssetUnloader : NoaUnloadAssetsCallbacks
{
// Example of logging memory usage before and after asset unloading.
public override void OnBeforeUnloadAssets()
{
Debug.Log($"Total allocated memory before Unload Assets: {NoaProfiler.LatestMemoryInfo.CurrentAllocatedMemoryMB} MB");
Debug.Log($"Mono used memory before Unload Assets: {NoaProfiler.LatestMemoryInfo.CurrentMonoUsedSizeMB} MB");
Debug.Log($"Total reserved memory before Unload Assets: {NoaProfiler.LatestMemoryInfo.CurrentReservedMemoryMB} MB");
}
public override void OnAfterUnloadAssets()
{
GC.Collect();
Debug.Log($"Total allocated memory after Unload Assets: {NoaProfiler.LatestMemoryInfo.CurrentAllocatedMemoryMB} MB");
Debug.Log($"Mono used memory after Unload Assets: {NoaProfiler.LatestMemoryInfo.CurrentMonoUsedSizeMB} MB");
Debug.Log($"Total reserved memory after Unload Assets: {NoaProfiler.LatestMemoryInfo.CurrentReservedMemoryMB} MB");
}
}
// Example of controlling whether to execute NOA Debugger’s asset unloading process with a custom flag.
public class ExampleOriginalAssetUnloader : NoaUnloadAssetsCallbacks
{
bool isAllowBaseUnloadAssets = true;
public override bool IsAllowBaseUnloadAssets => isAllowBaseUnloadAssets;
// Example of executing asset unloading only when memory usage exceeds a certain threshold.
const float allocatedMemoryThresholdMB = 500.0f;
public override void OnBeforeUnloadAssets()
{
float currentAllocatedMemoryMB = NoaProfiler.LatestMemoryInfo.CurrentAllocatedMemoryMB;
isAllowBaseUnloadAssets = currentAllocatedMemoryMB >= allocatedMemoryThresholdMB;
}
}
#endif
