Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Compile error in StandardShaderGUI.cs, GetMaterialProperties is inaccessible.

Discussion in 'General Graphics' started by ripridehi, Mar 27, 2015.

  1. ripridehi

    ripridehi

    Joined:
    Mar 27, 2015
    Posts:
    15
    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.
     
  2. ripridehi

    ripridehi

    Joined:
    Mar 27, 2015
    Posts:
    15
    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?
     
  3. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    2,005
    Its a bug, replace 'ShaderUtil' with 'MaterialEditor'

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

    use
    DetermineWorkflow( MaterialEditor.GetMaterialProperties(new Material[] { material }) );
     
    ripridehi likes this.
  4. ripridehi

    ripridehi

    Joined:
    Mar 27, 2015
    Posts:
    15
    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.
     
  5. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    2,005
    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.