From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/BaseClasses/CleanupManager.h | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Runtime/BaseClasses/CleanupManager.h (limited to 'Runtime/BaseClasses/CleanupManager.h') diff --git a/Runtime/BaseClasses/CleanupManager.h b/Runtime/BaseClasses/CleanupManager.h new file mode 100644 index 0000000..23c76c8 --- /dev/null +++ b/Runtime/BaseClasses/CleanupManager.h @@ -0,0 +1,37 @@ +#pragma once + +#if UNITY_EDITOR + +#include "Runtime/BaseClasses/GameObject.h" + +#include +#include + +class CleanupManager +{ +private: + struct MarkedComponent { + PPtr component; + std::string reason; + + bool operator==(PPtr const& comp) + { + return this->component == comp; + } + }; + +public: + CleanupManager() {} + + void MarkForDeletion(PPtr comp, std::string const& reason); + void Flush(); + + static void DidDestroyObjectNotification (Object* comp, void* userData); + +private: + std::list m_markedComponents; +}; + +CleanupManager& GetCleanupManager (); + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0