// "show surface shader" button
private static void ShowSurfaceShaderButton(Shader s)
{
var hasSurface = ShaderUtil.HasSurfaceShaders(s);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Surface shader", EditorStyles.miniButton);
if (hasSurface)
{
// check if this is a built-in shader (has no importer);
// we can't show generated code in that case
var builtinShader = (AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(s)) == null);
if (!builtinShader)
{
if (GUILayout.Button(Styles.showSurface, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
{
ShaderUtil.OpenParsedSurfaceShader(s);
GUIUtility.ExitGUI();
}
}
else
{
// See comment below why this is a button.
GUILayout.Button(Styles.builtinShader, GUI.skin.label);
}
}
else
{
// Note: PrefixLabel is sometimes buggy if followed by a non-control (like Label).
// We just want to show a label here, but have to pretend it's a button so it is treated like
// a control.
GUILayout.Button(Styles.no, GUI.skin.label);
}
EditorGUILayout.EndHorizontal();
}