summaryrefslogtreecommitdiff
path: root/Runtime/BaseClasses/CleanupManager.h
blob: 23c76c8360b2fed02e25e71edb248c84542d06bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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