using System.Collections.Generic; using System.Diagnostics; using UnityEngine; namespace CTS { public static class CTSShaders { private static Dictionary m_shaderLookup; static CTSShaders() { m_shaderLookup = new Dictionary(); Stopwatch stopwatch = Stopwatch.StartNew(); foreach (KeyValuePair shaderName in CTSConstants.shaderNames) { Shader shader = Shader.Find(shaderName.Value); if (shader != null) { m_shaderLookup.Add(shaderName.Value, shader); } } _ = stopwatch.ElapsedMilliseconds; _ = 0; } public static Shader GetShader(string shaderType) { if (m_shaderLookup.TryGetValue(shaderType, out var value)) { return value; } UnityEngine.Debug.LogErrorFormat("Could not load CTS shader : {0}. Make sure you add your CTS shader to pre-loaded assets!", shaderType); return null; } } }