VR4Medical/ICI/Library/PackageCache/com.unity.xr.core-utils@5b282bc7378d/Runtime/OnDestroyNotifier.cs
2025-07-29 13:45:50 +03:00

25 lines
678 B
C#

using System;
using UnityEngine;
namespace Unity.XR.CoreUtils
{
/// <summary>
/// <see cref="MonoBehaviour"/> that invokes a callback when it is destroyed.
/// </summary>
[AddComponentMenu("")]
[ExecuteInEditMode]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.core-utils@2.0/api/Unity.XR.CoreUtils.OnDestroyNotifier.html")]
public class OnDestroyNotifier : MonoBehaviour
{
/// <summary>
/// Called when this behavior is destroyed.
/// </summary>
public Action<OnDestroyNotifier> Destroyed { private get; set; }
void OnDestroy()
{
Destroyed?.Invoke(this);
}
}
}