Esempio n. 1
0
        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"))
                {
                    AmplifyShaderEditorWindow.ConvertShaderToASE(shader);
                }

                if (GUILayout.Button("Open in Text Editor"))
                {
                    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(CultureInfo.InvariantCulture), new GUILayoutOption[0]);
                EditorGUILayout.LabelField("LOD", ShaderUtilEx.GetLOD(shader).ToString(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]);
                CustomShaderInspector.ShowShaderProperties(shader);
            }
        }
Esempio n. 2
0
        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"))
                {
                    AmplifyShaderEditorWindow.ConvertShaderToASE(shader);
                }

                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);
            }
        }