Files
2026-03-04 10:03:45 +08:00

38 lines
924 B
C#

using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
namespace CTS
{
public static class CTSShaders
{
private static Dictionary<string, Shader> m_shaderLookup;
static CTSShaders()
{
m_shaderLookup = new Dictionary<string, Shader>();
Stopwatch stopwatch = Stopwatch.StartNew();
foreach (KeyValuePair<CTSShaderCriteria, string> 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;
}
}
}