mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
修正Utility生命周期注入OnDestroy和OnDrawGizmos无效的问题
修正Utility生命周期注入OnDestroy和OnDrawGizmos无效的问题
This commit is contained in:
@@ -225,15 +225,6 @@ namespace TEngine
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 释放Behaviour生命周期。
|
|
||||||
/// </summary>
|
|
||||||
public static void Release()
|
|
||||||
{
|
|
||||||
_MakeEntity();
|
|
||||||
_behaviour.Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void _MakeEntity()
|
private static void _MakeEntity()
|
||||||
{
|
{
|
||||||
if (_entity != null)
|
if (_entity != null)
|
||||||
@@ -241,11 +232,12 @@ namespace TEngine
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_entity = new GameObject("__MonoUtility__")
|
_entity = new GameObject("[Unity.Utility]")
|
||||||
{
|
{
|
||||||
hideFlags = HideFlags.HideAndDontSave
|
// hideFlags = HideFlags.HideAndDontSave
|
||||||
};
|
};
|
||||||
_entity.SetActive(true);
|
_entity.SetActive(true);
|
||||||
|
_entity.transform.SetParent(GameModule.Base.transform);
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (Application.isPlaying)
|
if (Application.isPlaying)
|
||||||
@@ -258,6 +250,22 @@ namespace TEngine
|
|||||||
_behaviour = _entity.AddComponent<MainBehaviour>();
|
_behaviour = _entity.AddComponent<MainBehaviour>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 释放Behaviour生命周期。
|
||||||
|
/// </summary>
|
||||||
|
public static void Shutdown()
|
||||||
|
{
|
||||||
|
if (_behaviour != null)
|
||||||
|
{
|
||||||
|
_behaviour.Release();
|
||||||
|
}
|
||||||
|
if (_entity != null)
|
||||||
|
{
|
||||||
|
Object.Destroy(_entity);
|
||||||
|
}
|
||||||
|
_entity = null;
|
||||||
|
}
|
||||||
|
|
||||||
private class MainBehaviour : MonoBehaviour
|
private class MainBehaviour : MonoBehaviour
|
||||||
{
|
{
|
||||||
private event UnityAction UpdateEvent;
|
private event UnityAction UpdateEvent;
|
||||||
|
@@ -77,7 +77,7 @@ namespace TEngine
|
|||||||
public static void Shutdown(ShutdownType shutdownType)
|
public static void Shutdown(ShutdownType shutdownType)
|
||||||
{
|
{
|
||||||
Log.Info("Shutdown Game Framework ({0})...", shutdownType);
|
Log.Info("Shutdown Game Framework ({0})...", shutdownType);
|
||||||
Utility.Unity.Release();
|
Utility.Unity.Shutdown();
|
||||||
RootModule rootModule = GetModule<RootModule>();
|
RootModule rootModule = GetModule<RootModule>();
|
||||||
if (rootModule != null)
|
if (rootModule != null)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user