diff --git a/Source/MaterialDef.cs b/Source/MaterialDef.cs index 354f99f..d520b6c 100644 --- a/Source/MaterialDef.cs +++ b/Source/MaterialDef.cs @@ -58,6 +58,8 @@ public class MaterialDef [Persistent(name = "shader")] public string shaderName = null; public Shader shader = null; + [Persistent] public bool preserveRenderQueue = false; + public Dictionary keywords; public Dictionary floats; public Dictionary colors; @@ -132,7 +134,12 @@ static object ParseColor(string value) public void ApplyTo(Material material) { - if (shader != null) material.shader = shader; + if (shader != null) { + // Replacing the shader resets the render queue to the shader's default. + var renderQueue = preserveRenderQueue ? material.renderQueue : -1; + material.shader = shader; + material.renderQueue = renderQueue; + } foreach (var kvp in keywords) { if (kvp.Value) material.EnableKeyword(kvp.Key);