// "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(); }
private static void ShowSurfaceShaderButton(Shader s) { bool flag = ShaderUtil.HasSurfaceShaders(s); EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.PrefixLabel("Surface shader", EditorStyles.miniButton); if (flag) { if (!(AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(s)) == null)) { if (GUILayout.Button(ShaderInspector.Styles.showSurface, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.ExpandWidth(false) })) { ShaderUtil.OpenParsedSurfaceShader(s); GUIUtility.ExitGUI(); } } else { GUILayout.Button(ShaderInspector.Styles.builtinShader, GUI.skin.label, new GUILayoutOption[0]); } } else { GUILayout.Button(ShaderInspector.Styles.no, GUI.skin.label, new GUILayoutOption[0]); } EditorGUILayout.EndHorizontal(); }