using System;
namespace PhxhSDK
{
///
/// 空的游戏物体
///
public sealed class Node : GameObjectWrapper, IDisposable
{
public Node():base(Utils.CreateGameObject(false))
{
}
public static Node Root = new Node();
///
/// 需要显式调用Dispose,销毁game object,editor模式下,系统会帮你检查node的泄漏问题
///
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)
{
}
}
}
}