Exemplo n.º 1
0
        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();
        }
        private void ShowCompiledCodeButton(Shader s)
        {
#if UNITY_2020_1_OR_NEWER
            using (new EditorGUI.DisabledScope(!EditorSettings.cachingShaderPreprocessor))
            {
                s_PreprocessOnly = EditorGUILayout.Toggle(Styles.togglePreprocess, s_PreprocessOnly);
#if UNITY_2020_2_OR_NEWER
                if (s_PreprocessOnly)
                {
                    s_StripLineDirectives = EditorGUILayout.Toggle(Styles.toggleStripLineDirective, s_StripLineDirectives);
                }
#endif
            }
#endif
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            EditorGUILayout.PrefixLabel("Compiled code", EditorStyles.miniButton);
            bool hasCode = ShaderUtilEx.HasShaderSnippets(s) || ShaderUtilEx.HasSurfaceShaders(s) || ShaderUtilEx.HasFixedFunctionShaders(s);
            if (hasCode)
            {
                GUIContent showCurrent = 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(System.Type.GetType("UnityEditor.ShaderInspectorPlatformsPopup, UnityEditor"), new object[] { s }));
                    GUIUtility.ExitGUI();
                }
                if (GUI.Button(rect, showCurrent, EditorStyles.miniButton))
                {
#if UNITY_2020_1
                    ShaderUtilEx.OpenCompiledShader(s, ShaderInspectorPlatformsPopupEx.GetCurrentMode(), ShaderInspectorPlatformsPopupEx.GetCurrentPlatformMask(), ShaderInspectorPlatformsPopupEx.GetCurrentVariantStripping() == 0, s_PreprocessOnly);
#elif UNITY_2020_2_OR_NEWER
                    ShaderUtilEx.OpenCompiledShader(s, ShaderInspectorPlatformsPopupEx.GetCurrentMode(), ShaderInspectorPlatformsPopupEx.GetCurrentPlatformMask(), ShaderInspectorPlatformsPopupEx.GetCurrentVariantStripping() == 0, s_PreprocessOnly, s_StripLineDirectives);
#else
                    ShaderUtilEx.OpenCompiledShader(s, ShaderInspectorPlatformsPopupEx.GetCurrentMode(), ShaderInspectorPlatformsPopupEx.GetCurrentPlatformMask(), ShaderInspectorPlatformsPopupEx.GetCurrentVariantStripping() == 0);
#endif
                    GUIUtility.ExitGUI();
                }
            }
            else
            {
                GUILayout.Button("none (precompiled shader)", GUI.skin.label, new GUILayoutOption[0]);
            }
            EditorGUILayout.EndHorizontal();
        }