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(); }
void DrawDitherPaletteList() { 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) { PostProcessDither target = ((PostProcessDither)postprocessDither.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(); }