private void ShowCompiledCodeButton(Shader s) { EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.PrefixLabel("Compiled code", EditorStyles.miniButton); bool flag = ShaderUtilEx.HasShaderSnippets(s) || ShaderUtilEx.HasSurfaceShaders(s) || ShaderUtilEx.HasFixedFunctionShaders(s); if (flag) { GUIContent showCurrent = CustomShaderInspector.Styles.showCurrent; Rect rect = GUILayoutUtility.GetRect(showCurrent, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); Rect position = new Rect(rect.xMax - 16f, rect.y, 16f, rect.height); if (EditorGUIEx.ButtonMouseDown(position, GUIContent.none, FocusType.Passive, GUIStyle.none)) { Rect last = GUILayoutUtilityEx.TopLevel_GetLast(); PopupWindow.Show(last, ( PopupWindowContent )Activator.CreateInstance(Type.GetType("UnityEditor.ShaderInspectorPlatformsPopup, UnityEditor"), new object[] { s })); GUIUtility.ExitGUI(); } if (GUI.Button(rect, showCurrent, EditorStyles.miniButton)) { ShaderUtilEx.OpenCompiledShader(s, ShaderInspectorPlatformsPopupEx.GetCurrentMode(), ShaderInspectorPlatformsPopupEx.GetCurrentPlatformMask(), ShaderInspectorPlatformsPopupEx.GetCurrentVariantStripping() == 0); GUIUtility.ExitGUI(); } } else { GUILayout.Button("none (precompiled shader)", GUI.skin.label, new GUILayoutOption[0]); } EditorGUILayout.EndHorizontal(); }
public virtual void OnEnable() { Shader s = this.target as Shader; ShaderUtilEx.FetchCachedErrors(s); }
public override void OnInspectorGUI() { Shader shader = this.target as Shader; if (shader == null) { return; } GUI.enabled = true; GUILayout.Space(3); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Open in Shader Editor")) { #if UNITY_2018_3_OR_NEWER ASEPackageManagerHelper.SetupLateShader(shader); #else AmplifyShaderEditorWindow.ConvertShaderToASE(shader); #endif } if (GUILayout.Button("Open in Text Editor")) { if (UIUtils.IsUnityNativeShader(shader)) { Debug.LogWarningFormat("Action not allowed. Attempting to load the native {0} shader into Text Editor", shader.name); } else { AssetDatabase.OpenAsset(shader, 1); } } } GUILayout.EndHorizontal(); GUILayout.Space(5); EditorGUI.indentLevel = 0; this.ShowShaderCodeArea(shader); if (shader.isSupported) { EditorGUILayout.LabelField("Cast shadows", (!ShaderUtilEx.HasShadowCasterPass(shader)) ? "no" : "yes", new GUILayoutOption[0]); EditorGUILayout.LabelField("Render queue", ShaderUtilEx.GetRenderQueue(shader).ToString(System.Globalization.CultureInfo.InvariantCulture), new GUILayoutOption[0]); EditorGUILayout.LabelField("LOD", ShaderUtilEx.GetLOD(shader).ToString(System.Globalization.CultureInfo.InvariantCulture), new GUILayoutOption[0]); EditorGUILayout.LabelField("Ignore projector", (!ShaderUtilEx.DoesIgnoreProjector(shader)) ? "no" : "yes", new GUILayoutOption[0]); string label; switch (ShaderEx.GetDisableBatching(shader)) { case DisableBatchingType.False: label = "no"; break; case DisableBatchingType.True: label = "yes"; break; case DisableBatchingType.WhenLODFading: label = "when LOD fading is on"; break; default: label = "unknown"; break; } EditorGUILayout.LabelField("Disable batching", label, new GUILayoutOption[0]); #if UNITY_2018_3_OR_NEWER int shaderActiveSubshaderIndex = ShaderUtilEx.GetShaderActiveSubshaderIndex(shader); int sRPBatcherCompatibilityCode = ShaderUtilEx.GetSRPBatcherCompatibilityCode(shader, shaderActiveSubshaderIndex); string label2 = (sRPBatcherCompatibilityCode != 0) ? "not compatible" : "compatible"; EditorGUILayout.LabelField("SRP Batcher", label2); if (sRPBatcherCompatibilityCode != 0) { EditorGUILayout.HelpBox(ShaderUtilEx.GetSRPBatcherCompatibilityIssueReason(shader, shaderActiveSubshaderIndex, sRPBatcherCompatibilityCode), MessageType.Info); } #endif CustomShaderInspector.ShowShaderProperties(shader); } }