单例对象销毁时的检查,修正由此错误的销毁单例对象的bug

This commit is contained in:
沈挺
2024-07-09 18:49:55 +08:00
parent 9afda78735
commit e53ceb0095

View File

@@ -36,7 +36,10 @@ namespace GameBase
protected virtual void OnDestroy()
{
Release();
if (this == _instance)
{
Release();
}
}
/// <summary>
@@ -96,7 +99,7 @@ namespace GameBase
}
}
if(_instance == null)
if (_instance == null)
{
Log.Error($"Can't create SingletonBehaviour<{typeof(T)}>");
}