private static void setVariantsEnabledForSurfaceShaders(bool enable)
        {
            foreach (var path in Directory.GetFiles(LEAP_GRAPHIC_SHADER_FOLDER, "*.shader", SearchOption.AllDirectories))
            {
                var shader = AssetDatabase.LoadAssetAtPath <Shader>(path);
                if (shader == null)
                {
                    continue;
                }

                if (VariantEnabler.IsSurfaceShader(shader))
                {
                    VariantEnabler.SetShaderVariantsEnabled(shader, enable);
                }
            }
            AssetDatabase.Refresh();
        }
Beispiel #2
0
        protected override void init(SerializedProperty property)
        {
            base.init(property);

            _uv0       = property.FindPropertyRelative("_useUv0");
            _uv1       = property.FindPropertyRelative("_useUv1");
            _uv2       = property.FindPropertyRelative("_useUv2");
            _uv3       = property.FindPropertyRelative("_useUv3");
            _colors    = property.FindPropertyRelative("_useColors");
            _bakedTint = property.FindPropertyRelative("_bakedTint");
            _normals   = property.FindPropertyRelative("_useNormals");

            drawCustom(rect => {
                rect.y += HEADER_HEADROOM;
                EditorGUI.LabelField(rect, "Mesh Settings", EditorStyles.boldLabel);
            }, HEADER_HEADROOM + EditorGUIUtility.singleLineHeight);

            increaseIndent();

            drawCustom(rect => {
                Rect left, right;
                rect.SplitHorizontally(out left, out right);
                EditorGUI.PropertyField(left, _uv0);
                EditorGUI.PropertyField(right, _uv1);
            }, EditorGUIUtility.singleLineHeight);

            drawCustom(rect => {
                Rect left, right;
                rect.SplitHorizontally(out left, out right);
                EditorGUI.PropertyField(left, _uv2);
                EditorGUI.PropertyField(right, _uv3);
            }, EditorGUIUtility.singleLineHeight);

            drawCustom(rect => {
                Rect left, right;
                rect.SplitHorizontally(out left, out right);
                EditorGUI.PropertyField(left, _colors);
                if (_colors.boolValue)
                {
                    EditorGUI.PropertyField(right, _bakedTint);
                }
            }, EditorGUIUtility.singleLineHeight);

            drawCustom(rect => {
                Rect left, right;
                rect.SplitHorizontally(out left, out right);
                EditorGUI.PropertyField(left, _normals);
            }, EditorGUIUtility.singleLineHeight);

            decreaseIndent();

            drawCustom(rect => {
                rect.y     += HEADER_HEADROOM;
                rect.height = EditorGUIUtility.singleLineHeight;
                EditorGUI.LabelField(rect, "Rendering Settings", EditorStyles.boldLabel);
            }, HEADER_HEADROOM + EditorGUIUtility.singleLineHeight);

            increaseIndent();

            SerializedProperty shaderProp;

            tryGetProperty("_shader", out shaderProp);

            drawCustom(rect => {
                if (!shaderProp.hasMultipleDifferentValues)
                {
                    Shader shader = shaderProp.objectReferenceValue as Shader;
                    if (VariantEnabler.DoesShaderHaveVariantsDisabled(shader))
                    {
                        Rect left, right;
                        rect.SplitHorizontallyWithRight(out left, out right, SHADER_WARNING_FIX_WIDTH);

                        EditorGUI.HelpBox(left, "This shader has disabled variants, and will not function until they are enabled.", MessageType.Warning);
                        if (GUI.Button(right, "Enable"))
                        {
                            if (EditorUtility.DisplayDialog("Import Time Warning!", "The import time for this surface shader can take up to 2-3 minutes!  Are you sure you want to enable?", "Enable", "Not right now"))
                            {
                                VariantEnabler.SetShaderVariantsEnabled(shader, enable: true);
                                AssetDatabase.Refresh();
                            }
                        }
                    }
                }
            },
                       () => {
                Shader shader = shaderProp.objectReferenceValue as Shader;
                if (VariantEnabler.DoesShaderHaveVariantsDisabled(shader))
                {
                    return(SHADER_WARNING_HEIGHT);
                }
                else
                {
                    return(0);
                }
            });

            drawProperty("_shader");
            drawProperty("_visualLayer", includeChildren: true, disable: EditorApplication.isPlaying);
            drawProperty("_atlas", includeChildren: true, disable: EditorApplication.isPlaying);
        }