summaryrefslogtreecommitdiff
path: root/Runtime/BaseClasses/CleanupManager.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-14 22:50:43 +0800
committerchai <chaifix@163.com>2019-08-14 22:50:43 +0800
commit15740faf9fe9fe4be08965098bbf2947e096aeeb (patch)
treea730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/BaseClasses/CleanupManager.h
+Unity Runtime codeHEADmaster
Diffstat (limited to 'Runtime/BaseClasses/CleanupManager.h')
-rw-r--r--Runtime/BaseClasses/CleanupManager.h37
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