1 line
1.3 KiB
C#
1 line
1.3 KiB
C#
using System;
|
||
|
||
|
||
namespace PhxhSDK
|
||
|
||
{
|
||
|
||
/// <summary>
|
||
|
||
/// 空的游戏物体
|
||
|
||
/// </summary>
|
||
|
||
public sealed class Node : GameObjectWrapper, IDisposable
|
||
|
||
{
|
||
|
||
public Node():base(Utils.CreateGameObject(false))
|
||
|
||
{
|
||
|
||
}
|
||
|
||
|
||
|
||
public static Node Root = new Node();
|
||
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
|
||
/// 需要显式调用Dispose,销毁game object,editor模式下,系统会帮你检查node的泄漏问题
|
||
|
||
/// </summary>
|
||
|
||
public void Dispose()
|
||
|
||
{
|
||
|
||
Dispose(true);
|
||
|
||
#if UNITY_EDITOR
|
||
|
||
GC.SuppressFinalize(this); //自己释放了,不需要gc帮我调用析构函数
|
||
|
||
#endif
|
||
|
||
}
|
||
|
||
|
||
|
||
#if UNITY_EDITOR
|
||
|
||
~Node()
|
||
|
||
{
|
||
|
||
Dispose(false);
|
||
|
||
}
|
||
|
||
#endif
|
||
|
||
|
||
|
||
|
||
|
||
private void ReleaseUnmanagedResources()
|
||
{
|
||
Utils.Destroy(GoRoot);
|
||
}
|
||
|
||
|
||
|
||
private void Dispose(bool disposing)
|
||
|
||
{
|
||
|
||
if (!disposing)
|
||
|
||
{
|
||
|
||
DebugUtil.LogError(
|
||
"Node should call dispose method,or the inner game object wont destroy. node name: {0}", Name);
|
||
|
||
}
|
||
|
||
|
||
|
||
ReleaseUnmanagedResources();
|
||
|
||
if (disposing)
|
||
|
||
{
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
} |