Under review

Inspector exceptions when built-in shader is selected in the editor (v1.7)

Andy Buchanan 3 years ago • updated 3 years ago 5
I'm developing a shader remapping helper, but when I have one of the built-in shaders selected in an ObjectField ( e.g. "Standard (specular)" ) I'm getting the console spammed with this:

DirectoryNotFoundException: Could not find a part of the path "E:\Wish\Perforce\X\Main\Game\Unity5-PS4\Resources\unity_builtin_extra".
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/FileStream.cs:292)
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share)
(wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
System.IO.File.OpenRead (System.String path) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:363)
System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/StreamReader.cs:167)
System.IO.StreamReader..ctor (System.String path)
(wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor (string)
System.IO.File.OpenText (System.String path) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:368)
System.IO.File.ReadAllLines (System.String path) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:560)
ShaderForge.SF_Parser.ExtractShaderForgeData (UnityEngine.Shader s, System.Single& version, Boolean setPath, Boolean findRenderers, Boolean findLOD)
ShaderForge.SF_Parser.ContainsShaderForgeData (UnityEngine.Shader s)
UnityEditor.ShaderForgeInspector.AnalyzeShader ()
UnityEditor.ShaderForgeInspector.OnEnable ()

Under review
If you mean Shader Forge 1.17 - update to 1.19 and it should be fine, unless this is due to something else.
Yes v1.17. Cannot upgrade yet due to the other problem; can't go to Unity 5.2 for a week or two.
Think this is a different issue, because the other problem was on v1.18 not v1.17

It could possibly be that perforce is disallowing access to the file or something?
AFAICT the "E:\Wish\Perforce\X\Main\Game\Unity5-PS4\Resources\unity_builtin_extra" does not exist when in the Editor, it is only created when the project is built. I think the Unity editor secretly patches though to the master copy in $Unity/Editor/Data for it's usual operations. If I had to guess, I'd say you can't load the built-in shaders code with the same method used for normal project shaders?
Still throwing an exception on v1.19 and Unity 5.20f3
//Copyright (c) 2015, Wish Studios ltd.  All rights reserved.

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

public class BreakTheShaderForgeInspector : EditorWindow 
    [MenuItem( "Window/Break the Shader Forge Inspector" )]
    static void Init()
        BreakTheShaderForgeInspector window = (BreakTheShaderForgeInspector)EditorWindow.GetWindow( typeof( BreakTheShaderForgeInspector ) );
        window.minSize = new Vector2( 400, 300 );

    Shader pickABuiltInShader = null;

    void ShowDialog()
        GUILayout.Label( "Annoy the Shader Forge Inspector" );
        GUILayout.Label( "Pick a built-in shader (one without an icon, e.g. 'Standard')" );
        GUILayout.Label( "below using the pop-up and check the errors" );
        pickABuiltInShader = EditorGUILayout.ObjectField( "Shader", pickABuiltInShader, typeof( Shader ), true ) as Shader;
        GUILayout.Label( "" ); // Spacer

    void OnGUI()