NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Framework/Wrapper/Node.cs

1 line
1.3 KiB
C#
Raw Normal View History

2023-10-19 15:00:19 +08:00
using System; using UnityEngine; namespace Framework.Wrapper { /// <summary> /// 空的游戏物体 /// </summary> public sealed class Node : GameObjectWrapper, IDisposable { public Node():base(GameObjectFactory.Create(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() { GameObjectFactory.Destroy(_gameObject); } 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) { } } } }