Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/MyUtility/UtilityOnDestroyHandler.cs
2026-02-21 16:45:37 +08:00

32 lines
551 B
C#

using System;
using UnityEngine;
namespace MyUtility
{
public class UtilityOnDestroyHandler : MonoBehaviour
{
private bool m_isHandlingDisabled;
public Action m_onDestroy;
public void DestroyWithoutHandling()
{
m_isHandlingDisabled = true;
m_onDestroy = null;
UnityEngine.Object.Destroy(this);
}
private void OnDestroy()
{
if (m_onDestroy != null)
{
m_onDestroy();
}
else if (!m_isHandlingDisabled)
{
Debug.LogError("UtilityOnDestroyHandler: OnDestroy: destroy handler was not set!");
}
}
}
}