protected void BuildMaterials() { //Create materials for each blending mode //Blending modes cannot be changed by MaterialPropertyBlocks, //so we need to have a separate material to pass to each layer based on its setting _materials = new Dictionary <ShaderBlendMode, Material>(); HashSet <Shader> layerShaders = new HashSet <Shader>(); foreach (Depthkit_ZeroDaysLookLayer layer in _layers) { if (layer != null && layer.Shader != null) { layerShaders.Add(layer.Shader); } } foreach (BlendMode mode in BlendMode.GetValues(typeof(BlendMode))) { foreach (Shader shader in layerShaders) { ShaderBlendMode sbm = new ShaderBlendMode(shader, mode); Material mat = new Material(shader); mat.SetInt("_SrcMode", (int)GetSrcMode(mode)); mat.SetInt("_DstMode", (int)GetDstMode(mode)); mat.SetInt("_BlendEnum", (int)mode); _materials.Add(sbm, mat); } } }