using System.Collections.Generic; using System.Diagnostics; using UnityEngine; namespace CTS { public static class CTSMaterials { private static Dictionary m_materialLookup = new Dictionary(); public static Material GetMaterial(string shaderType, CTSProfile profile) { if (profile.m_useMaterialControlBlock && m_materialLookup.TryGetValue(shaderType + ":" + profile.name, out var value)) { return value; } Shader shader = CTSShaders.GetShader(shaderType); if (shader == null) { UnityEngine.Debug.LogErrorFormat("Could not create CTS material for shader : {0}. Make sure you add your CTS shader is pre-loaded!", shaderType); return null; } Stopwatch stopwatch = Stopwatch.StartNew(); value = new Material(shader) { name = shaderType + ":" + profile.name }; if (profile.m_useMaterialControlBlock) { value.hideFlags = HideFlags.DontSave; m_materialLookup.Add(value.name, value); } _ = stopwatch.ElapsedMilliseconds; _ = 5; return value; } } }