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

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

View File

@@ -35,9 +35,12 @@ namespace GameBase
}
protected virtual void OnDestroy()
{
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)}>");
}