Пример #1
0
    void DrawColorRampList()
    {
        float buttonHeight = 24f;

        EditorGUILayout.BeginVertical();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Color Ramp");
        int saveIndentLevel = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;
        Rect contentRect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect());

        EditorGUILayout.EndHorizontal();
        Rect currentRect = new Rect(contentRect.x, contentRect.y, contentRect.width, buttonHeight);

        EditorGUI.indentLevel = saveIndentLevel;
        foreach (Texture2D ramp in colorRamps)
        {
            if (GUI.Button(currentRect, new GUIContent("", ramp.name)))
            {
                PostProcessDither target = ((PostProcessDither)postprocessDither.objectReferenceValue);
                if (target != null)
                {
                    target.SetPalette(ramp);
                }
            }
            GUI.DrawTexture(currentRect.AddMargin(4f), ramp, ScaleMode.ScaleAndCrop);
            currentRect = new Rect(currentRect.x, currentRect.y + currentRect.height + 2, currentRect.width, currentRect.height);
        }
        GUILayout.Space((buttonHeight + 2) * colorRamps.Length);
        EditorGUILayout.EndVertical();
    }
Пример #2
0
    void DrawScanlineOptions()
    {
        if (useScanlines.boolValue = EditorGUILayout.BeginToggleGroup(new GUIContent("Scanlines", "Overlay scanline pattern"), useScanlines.boolValue))
        {
            EditorGUI.indentLevel++;

            EditorGUILayout.PropertyField(scanlinesScale, new GUIContent("Scale"));
            EditorGUILayout.PropertyField(scanlineIntensity, new GUIContent("Intensity"));

            float buttonSize = 32f;
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Pattern");
            int saveIndentLevel = EditorGUI.indentLevel;
            EditorGUI.indentLevel = 0;
            Rect contentRect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect());
            EditorGUILayout.EndHorizontal();
            Rect currentRect = new Rect(contentRect.x, contentRect.y, buttonSize, buttonSize);

            EditorGUILayout.BeginVertical();
            foreach (Texture2D scanline in scanlines)
            {
                GetScanlineButtonColor(scanline);
                if (GUI.Button(currentRect, new GUIContent("", scanline.name)))
                {
                    PostProcessScanlines target = ((PostProcessScanlines)postprocessScanlines.objectReferenceValue);
                    if (target != null)
                    {
                        target.SetScanlineTexture(scanline);
                    }
                }
                GUI.DrawTexture(currentRect.AddMargin(4f), scanline, ScaleMode.ScaleToFit);
                currentRect = new Rect(currentRect.x + buttonSize, currentRect.y, currentRect.width, currentRect.height);
            }

            GUILayout.Space(32 + 2);
            EditorGUI.indentLevel = saveIndentLevel;
            GUILayout.EndVertical();

            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndToggleGroup();
        GUI.color = Color.white;
    }
Пример #3
0
    void DrawDitherPatternList()
    {
        float buttonHeight = 24f;

        EditorGUILayout.BeginVertical();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Pattern");
        int saveIndentLevel = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;
        Rect contentRect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect());

        EditorGUILayout.EndHorizontal();
        Rect currentRect  = new Rect(contentRect.x, contentRect.y, (contentRect.width) * 0.6f, buttonHeight);
        Rect currentRect2 = new Rect(contentRect.x + (contentRect.width) * 0.6f, contentRect.y, (contentRect.width) * 0.4f, buttonHeight);

        EditorGUI.indentLevel = saveIndentLevel;
        foreach (Texture2D ditherPattern in ditherPatterns)
        {
            PostProcessDither target = ((PostProcessDither)postprocessDither.objectReferenceValue);
            if (target != null)
            {
                if (target.currentDitherTexture == ditherPattern)
                {
                    GUI.Toggle(currentRect, true, "", GUI.skin.GetStyle("Button"));
                }
                else
                {
                    if (GUI.Button(currentRect, new GUIContent("", ditherPattern.name)))
                    {
                        target.SetDitherPattern(ditherPattern);
                    }
                }
            }
            GUI.DrawTexture(currentRect.AddMargin(4f), ditherPattern, ScaleMode.StretchToFill);
            GUI.Label(currentRect2, " " + ditherPattern.height + "x" + ditherPattern.height + " (" + Mathf.RoundToInt(ditherPattern.width / ditherPattern.height) + " Levels)");
            currentRect  = new Rect(currentRect.x, currentRect.y + currentRect.height + 2, currentRect.width, currentRect.height);
            currentRect2 = new Rect(currentRect2.x, currentRect2.y + currentRect2.height + 2, currentRect2.width, currentRect2.height);
        }
        GUILayout.Space((buttonHeight + 2) * ditherPatterns.Length);
        EditorGUILayout.EndVertical();
    }
Пример #4
0
    void DrawSubPixelOptions()
    {
        if (useSubPixels.boolValue = EditorGUILayout.BeginToggleGroup(new GUIContent("Subpixels", "Subpixel layouts and patterns"), useSubPixels.boolValue))
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(subPixelScale, new GUIContent("Scale"));

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Color Mode");
            EditorGUI.BeginChangeCheck();
            GUILayout.Toggle(pixelColorMode.boolValue, "RGB", GUI.skin.GetStyle("Button"));
            GUILayout.Toggle(!pixelColorMode.boolValue, "CMY", GUI.skin.GetStyle("Button"));
            if (EditorGUI.EndChangeCheck())
            {
                pixelColorMode.boolValue = !pixelColorMode.boolValue;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Brightness");
            int saveIndentLevel = EditorGUI.indentLevel;
            EditorGUI.indentLevel = 0;
            brightness.floatValue = EditorGUILayout.Slider(brightness.floatValue, 0, 0.2f);
            EditorGUI.indentLevel = saveIndentLevel;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Contrast");
            saveIndentLevel       = EditorGUI.indentLevel;
            EditorGUI.indentLevel = 0;
            contrast.floatValue   = EditorGUILayout.Slider(contrast.floatValue, -1, 1);
            EditorGUI.indentLevel = saveIndentLevel;
            EditorGUILayout.EndHorizontal();

            float buttonSize = 32f;
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Subpixel Image");
            saveIndentLevel       = EditorGUI.indentLevel;
            EditorGUI.indentLevel = 0;
            Rect contentRect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect());
            EditorGUILayout.EndHorizontal();
            Rect currentRect = new Rect(contentRect.x, contentRect.y, buttonSize, buttonSize);

            EditorGUILayout.BeginVertical();
            foreach (Texture2D pixelTexture in pixelTextures)
            {
                GetPixelButtonColor(pixelTexture);
                if (GUI.Button(currentRect, new GUIContent("", pixelTexture.name)))
                {
                    PostProcessSubPixels target = ((PostProcessSubPixels)postprocessSubPixels.objectReferenceValue);
                    if (target != null)
                    {
                        target.SetSubPixelTexture(pixelTexture);
                    }
                }
                GUI.DrawTexture(currentRect.AddMargin(4f), pixelTexture, ScaleMode.ScaleToFit);
                currentRect = new Rect(currentRect.x + buttonSize, currentRect.y, currentRect.width, currentRect.height);
            }

            currentRect = new Rect(contentRect.x, contentRect.y + buttonSize + 2, buttonSize, buttonSize);
            foreach (Texture2D pixelShape in pixelShapes)
            {
                GetPixelButtonColor(pixelShape);
                if (GUI.Button(currentRect, new GUIContent("", pixelShape.name)))
                {
                    ((PostProcessSubPixels)postprocessSubPixels.objectReferenceValue).SetSubPixelTexture(pixelShape);
                }
                GUI.DrawTexture(currentRect.AddMargin(4f), pixelShape, ScaleMode.ScaleToFit);
                currentRect = new Rect(currentRect.x + buttonSize, currentRect.y, currentRect.width, currentRect.height);
            }
            GUILayout.Space(32 + 16 + 2);
            EditorGUI.indentLevel = saveIndentLevel;
            GUILayout.EndVertical();

            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndToggleGroup();
        GUI.color = Color.white;
    }
Пример #5
0
    void DrawColorPaletteList()
    {
        float buttonHeight = 24f;

        EditorGUILayout.BeginVertical();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Palette");
        int saveIndentLevel = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;
        Rect contentRect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect());

        EditorGUILayout.EndHorizontal();
        Rect currentRect  = new Rect(contentRect.x, contentRect.y, (contentRect.width) * 0.45f, buttonHeight);
        Rect currentRect2 = new Rect(contentRect.x + (contentRect.width) * 0.45f + 2, contentRect.y, (contentRect.width) * 0.1f, buttonHeight);
        Rect currentRect3 = new Rect(contentRect.x + (contentRect.width) * 0.55f + 4, contentRect.y, (contentRect.width) * 0.45f, buttonHeight);

        EditorGUI.indentLevel = saveIndentLevel;
        foreach (Texture2D palette in palettes)
        {
            Texture2D processedPalette = FindProcessedPalette(palette);
            if (processedPalette != null)
            {
                PostProcessColor target = ((PostProcessColor)postprocessColor.objectReferenceValue);
                if (target != null)
                {
                    if (target.currentPaletteTexture == processedPalette)
                    {
                        GUI.Toggle(currentRect, true, "", GUI.skin.GetStyle("Button"));
                    }
                    else
                    {
                        if (GUI.Button(currentRect, new GUIContent("", palette.name)))
                        {
                            target.SetPalette(processedPalette);
                        }
                    }
                }
            }
            GUI.DrawTexture(currentRect.AddMargin(4f), palette, ScaleMode.StretchToFill);

            if (GUI.Button(currentRect2.AddMargin(2f), new GUIContent("->", "Process palette")))
            {
                ProcessPalette(palette);
            }

            if (processedPalette != null)
            {
                float texWidth = currentRect3.width / 5f;
                Rect  texRect1 = new Rect(currentRect3.x + 0 * texWidth, currentRect3.y, texWidth, currentRect3.height);
                Rect  texRect2 = new Rect(currentRect3.x + 1 * texWidth, currentRect3.y, texWidth, currentRect3.height);
                Rect  texRect3 = new Rect(currentRect3.x + 2 * texWidth, currentRect3.y, texWidth, currentRect3.height);
                Rect  texRect4 = new Rect(currentRect3.x + 3 * texWidth, currentRect3.y, texWidth, currentRect3.height);
                Rect  texRect5 = new Rect(currentRect3.x + 4 * texWidth, currentRect3.y, texWidth, currentRect3.height);

                float texTileWidth = (float)1 / 32f;
                EditorGUI.DrawRect(currentRect3, new Color(0.2f, 0.2f, 0.2f));

                GUI.DrawTextureWithTexCoords(texRect1.AddMargin(2).SquareInsideRect(), processedPalette, new Rect(0 * texTileWidth, 0, texTileWidth, 0.3333f));
                GUI.DrawTextureWithTexCoords(texRect2.AddMargin(2).SquareInsideRect(), processedPalette, new Rect(7 * texTileWidth, 0, texTileWidth, 0.3333f));
                GUI.DrawTextureWithTexCoords(texRect3.AddMargin(2).SquareInsideRect(), processedPalette, new Rect(15 * texTileWidth, 0, texTileWidth, 0.3333f));
                GUI.DrawTextureWithTexCoords(texRect4.AddMargin(2).SquareInsideRect(), processedPalette, new Rect(23 * texTileWidth, 0, texTileWidth, 0.3333f));
                GUI.DrawTextureWithTexCoords(texRect5.AddMargin(2).SquareInsideRect(), processedPalette, new Rect(31 * texTileWidth, 0, texTileWidth, 0.3333f));
            }
            else
            {
                GUI.Label(currentRect3.AddMargin(4), "Processing Required");
            }
            currentRect  = new Rect(currentRect.x, currentRect.y + currentRect.height + 2, currentRect.width, currentRect.height);
            currentRect2 = new Rect(currentRect2.x, currentRect2.y + currentRect2.height + 2, currentRect2.width, currentRect2.height);
            currentRect3 = new Rect(currentRect3.x, currentRect3.y + currentRect3.height + 2, currentRect3.width, currentRect3.height);
        }
        GUILayout.Space((buttonHeight + 2) * palettes.Length);
        EditorGUILayout.EndVertical();
    }