summaryrefslogtreecommitdiff
path: root/Runtime/Camera/GraphicsSettings.cpp
blob: 004f6edd4edf20962cb8da63ae9d546d65f17b0f (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "UnityPrefix.h"
#include "GraphicsSettings.h"
#include "RenderManager.h"
#include "Runtime/BaseClasses/ManagerContext.h"
#include "Runtime/Serialize/TransferFunctions/SerializeTransfer.h"
#if UNITY_EDITOR
#include "Runtime/Misc/ResourceManager.h"
#endif


GraphicsSettings::GraphicsSettings (MemLabelId label, ObjectCreationMode mode)
:	Super(label, mode)
,	m_NeedToInitializeDefaultShaders(false)
{
}

GraphicsSettings::~GraphicsSettings ()
{
}


void GraphicsSettings::InitializeClass ()
{
	RenderManager::InitializeClass();
}

void GraphicsSettings::CleanupClass ()
{
	RenderManager::CleanupClass();
}


void GraphicsSettings::SetDefaultAlwaysIncludedShaders()
{
	#if UNITY_EDITOR
	m_AlwaysIncludedShaders.clear();
	if (BuiltinResourceManager::AreResourcesInitialized())
		m_AlwaysIncludedShaders.push_back(GetBuiltinExtraResource<Shader> ("Normal-Diffuse.shader"));
	else
		m_NeedToInitializeDefaultShaders = true;
	SetDirty();
	#endif
}

bool GraphicsSettings::IsAlwaysIncludedShader (PPtr<Shader> shader) const
{
	for (int i = 0; i < m_AlwaysIncludedShaders.size (); ++i)
		if (m_AlwaysIncludedShaders[i] == shader)
			return true;

	return false;
}

#if UNITY_EDITOR

void GraphicsSettings::AddAlwaysIncludedShader (PPtr<Shader> shader)
{
	m_AlwaysIncludedShaders.push_back (shader);
	SetDirty ();
}

#endif

void GraphicsSettings::Reset ()
{
	Super::Reset ();
	SetDefaultAlwaysIncludedShaders ();
}

template<class TransferFunction>
void GraphicsSettings::Transfer (TransferFunction& transfer)
{
	Super::Transfer (transfer);
	transfer.Transfer (m_AlwaysIncludedShaders, "m_AlwaysIncludedShaders");
}

IMPLEMENT_CLASS_HAS_INIT (GraphicsSettings)
IMPLEMENT_OBJECT_SERIALIZE (GraphicsSettings)
GET_MANAGER (GraphicsSettings)