Forest_Client/Forest/Assets/PhxhSDK/Phxh/Wrapper/Node.cs

1 line
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 objecteditor模式下系统会帮你检查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 methodor the inner game object wont destroy. node name: {0}", Name);
}
ReleaseUnmanagedResources();
if (disposing)
{
}
}
}
}