summaryrefslogtreecommitdiff
path: root/Runtime/Shaders/ShaderNameRegistry.h
blob: 1643f4d1bffd66cf54808874fbbf1220a958e5c1 (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
#pragma once

#include "Runtime/BaseClasses/GameManager.h"
#include <string>
#include <map>
#include "Runtime/Shaders/NameToObjectMap.h"
#include "Runtime/Modules/ExportModules.h"

using std::string;

class Shader;
typedef std::vector< PPtr<Shader> > ShaderPtrVector;


class EXPORT_COREMODULE ScriptMapper : public GlobalGameManager
{
public:
	typedef std::multimap<UnityStr, PPtr<Shader> > StringToShader;
	REGISTER_DERIVED_CLASS (ScriptMapper, GlobalGameManager)
	DECLARE_OBJECT_SERIALIZE (ScriptMapper)
	
	typedef NameToObjectMap<Shader, std::map<PPtr<Shader>, UnityStr>, std::multimap<UnityStr, PPtr<Shader> > > Shaders;
	
	ScriptMapper (MemLabelId label, ObjectCreationMode mode);
	// virtual ~ScriptMapper (); declared-by-macro

	// Add a shader to the system.
	void AddShader (Shader& ptr);
	void AddBuiltinShader (const std::string& className, PPtr<Shader> ptr);

	// Get a shader by name.
	// If the shader could not be loaded (e.g. because it was deleted), it is removed from the master list.
	Shader* FindShader (const string &name);

	bool ShouldIgnoreInGarbageDependencyTracking ();
	
	#if UNITY_EDITOR
	
	Shader *GetDefaultShader() { return FindShader( "Diffuse" ); }
	
	const Shaders& GetShaders () { return m_Shaders; }
	void SetShaders (const Shaders& shaders) { m_Shaders = shaders; }
	
	#endif // UNITY_EDITOR
	
private:
	Shaders	m_Shaders;
};

ScriptMapper& GetScriptMapper ();
ScriptMapper* GetScriptMapperPtr ();


Shader* FindShaderLabShader (const std::string& name, ShaderPtrVector& shaderLookup, bool useLookup);