Пример #1
0
    void GetScanlineButtonColor(Texture2D scanlineTexture)
    {
        PostProcessScanlines target = ((PostProcessScanlines)postprocessScanlines.objectReferenceValue);

        if (target != null)
        {
            bool isSelected = (target.renderMaterial.GetTexture("_Scanline") == scanlineTexture);
            if (isSelected)
            {
                GUI.color = Color.gray;
            }
            else
            {
                GUI.color = Color.white;
            }
        }
    }
Пример #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;
    }