Shader.name / Shader.Find incompatibility

If I set a shader for a material in the inspector to say, diffuse, then:

myMaterial.shader.name returns “Normal-Diffuse”,
and Shader.Find(“Normal-Diffuse”) returns null.

Similary for Diffuse (fast)
myMaterial.shader.name returns “Normal-DiffuseFast”,
and Shader.Find(“Normal-DiffuseFast”) returns null.

Shader.Find(" Diffuse")
Shader.Find(" Diffuse (fast)")

both work correctly though.

Why is this? And are there any reliable ways to convert a shader.name for use in Shader.Find statement?

Has anyone come up with an answer to this, yet? I am putting the final touches on model serialization and would like this answer to re-create materials from loaded models correctly…


David Robinson
Coole Immersive, Inc.

No, shader.name is not the name that is used for Shader.Find. Shader.Find uses the name of the shader as it appears in material inspector (and written at start of shader). Shader.name returns the name of the shader file.

Yeah, it is inconsistent.