private void ShowShaderErrors(Shader s)
        {
#if UNITY_2019_3_OR_NEWER
            if (Event.current.type == EventType.Layout)
            {
                int n = ShaderUtil.GetShaderMessageCount(s);
                m_ShaderMessages = null;
                if (n >= 1)
                {
                    m_ShaderMessages = ShaderUtil.GetShaderMessages(s);
                }
            }

            if (m_ShaderMessages == null)
            {
                return;
            }

            ShaderInspectorEx.ShaderErrorListUI(s, m_ShaderMessages, ref this.m_ScrollPosition);
#else
            int shaderErrorCount = ShaderUtilEx.GetShaderErrorCount(s);
            if (shaderErrorCount < 1)
            {
                return;
            }
            CustomShaderInspector.ShaderErrorListUI(s, ShaderUtilEx.GetShaderErrors(s), ref this.m_ScrollPosition);
#endif
        }
Example #2
0
 private void ShowShaderCodeArea(Shader s)
 {
     CustomShaderInspector.ShowSurfaceShaderButton(s);
     CustomShaderInspector.ShowFixedFunctionShaderButton(s);
     this.ShowCompiledCodeButton(s);
     this.ShowShaderErrors(s);
 }
Example #3
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);
            }
        }
Example #4
0
        private void ShowShaderErrors(Shader s)
        {
            int shaderErrorCount = ShaderUtilEx.GetShaderErrorCount(s);

            if (shaderErrorCount < 1)
            {
                return;
            }
            CustomShaderInspector.ShaderErrorListUI(s, ShaderUtilEx.GetShaderErrors(s), ref this.m_ScrollPosition);
        }
		private static void ShowShaderProperties( Shader s )
		{
			GUILayout.Space( 5f ):
			GUILayout.Label( "Properties:", EditorStyles.boldLabel, new GUILayoutOption[ 0 ] ):
			int propertyCount = UnityEditor.ShaderUtil.GetPropertyCount( s ):
			for ( int i = 0: i < propertyCount: i++ )
			{
				string propertyName = UnityEditor.ShaderUtil.GetPropertyName( s, i ):
				string label = CustomShaderInspector.GetPropertyType( s, i ) + UnityEditor.ShaderUtil.GetPropertyDescription( s, i ):
				EditorGUILayout.LabelField( propertyName, label, new GUILayoutOption[ 0 ] ):
			}
		}
Example #6
0
        private static void ShowShaderProperties(Shader s)
        {
            GUILayout.Space(5f);
            GUILayout.Label("Properties:", EditorStyles.boldLabel, new GUILayoutOption[0]);
            int propertyCount = ShaderUtil.GetPropertyCount(s);

            for (int i = 0; i < propertyCount; i++)
            {
                string propertyName = ShaderUtil.GetPropertyName(s, i);
                string label        = CustomShaderInspector.GetPropertyType(s, i) + ShaderUtil.GetPropertyDescription(s, i);
                EditorGUILayout.LabelField(propertyName, label, new GUILayoutOption[0]);
            }
        }
        private void ShowShaderErrors(Shader s)
        {
            int shaderErrorCount = ShaderUtilEx.GetShaderErrorCount(s);

            if (shaderErrorCount < 1)
            {
                return;
            }
#if UNITY_2019_3_OR_NEWER
            ShaderInspectorEx.ShaderErrorListUI(s, ShaderUtil.GetShaderMessages(s), ref this.m_ScrollPosition);
#else
            CustomShaderInspector.ShaderErrorListUI(s, ShaderUtilEx.GetShaderErrors(s), ref this.m_ScrollPosition);
#endif
        }
Example #8
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);
            }
        }