mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
单例对象销毁时的检查,修正由此错误的销毁单例对象的bug
This commit is contained in:
@@ -36,7 +36,10 @@ namespace GameBase
|
|||||||
|
|
||||||
protected virtual void OnDestroy()
|
protected virtual void OnDestroy()
|
||||||
{
|
{
|
||||||
Release();
|
if (this == _instance)
|
||||||
|
{
|
||||||
|
Release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -96,7 +99,7 @@ namespace GameBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_instance == null)
|
if (_instance == null)
|
||||||
{
|
{
|
||||||
Log.Error($"Can't create SingletonBehaviour<{typeof(T)}>");
|
Log.Error($"Can't create SingletonBehaviour<{typeof(T)}>");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user