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

1 line
1.3 KiB
C#
Raw Normal View History

2024-06-12 15:01:54 +08:00
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) { } } } }