diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/BaseClasses/CleanupManager.h |
Diffstat (limited to 'Runtime/BaseClasses/CleanupManager.h')
-rw-r--r-- | Runtime/BaseClasses/CleanupManager.h | 37 |
1 files changed, 37 insertions, 0 deletions
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 <string> +#include <list> + +class CleanupManager +{ +private: + struct MarkedComponent { + PPtr<Unity::Component> component; + std::string reason; + + bool operator==(PPtr<Unity::Component> const& comp) + { + return this->component == comp; + } + }; + +public: + CleanupManager() {} + + void MarkForDeletion(PPtr<Unity::Component> comp, std::string const& reason); + void Flush(); + + static void DidDestroyObjectNotification (Object* comp, void* userData); + +private: + std::list<struct MarkedComponent> m_markedComponents; +}; + +CleanupManager& GetCleanupManager (); + +#endif
\ No newline at end of file |