Compile error in StandardShaderGUI.cs, GetMaterialProperties is inaccessible.

I downloaded the latest shader source from here.
Copied the Editor/StandardShaderGUI.cs to my project Assets/Editor folder, renamed the file and the class name in order to differentiate it from the existing class.
I get this error:
Assets/Editor/StandardShaderGUIMod.cs(203,47): error CS0122: `UnityEditor.ShaderUtil.GetMaterialProperties(UnityEngine.Object[ ])’ is inaccessible due to its protection level

I have not made any modifications to the code, this is straight out of the box.
Am I doing something wrong?

I’m trying to find my way around the relatively complex new Standard Shader, but I can’t even get the unmodified source to compile, so I’m kinda stuck. Any help would be appreciated.

It’s this line in function AssignNewShaderToMaterial():

DetermineWorkflow( ShaderUtil.GetMaterialProperties(new Material[ ] { material }) );

I commented out that line and forced workflow to specular, and now it compiles:
m_WorkflowMode = WorkflowMode.Specular;

Has anyone else encountered this? Is there a bug in the shader source, or am I wrong in expecting this to compile simply by copying the editor script?

This makes me suspicious too - how can I be sure the shader source I download from the archives is what is actually running in my specific build of Unity? Is there some sort of version number in the code, that I can also query at runtime to make sure they match?

Its a bug, replace ‘ShaderUtil’ with ‘MaterialEditor’

e.g. instead of
DetermineWorkflow( ShaderUtil.GetMaterialProperties(new Material[ ] { material }) );

use
DetermineWorkflow( MaterialEditor.GetMaterialProperties(new Material[ ] { material }) );

1 Like

Yes, that works, thanks. So it looks like the shader source provided in the download archives is not the actual source compiled into the editor.

Maybe, might just be an oversight. I logged it as a bug when I made my previous post, so hopefully some point soon it will be fixed.