public static void DrawColorGroupHorizontal(Rect rect, ColorGroup cg, Action onClick) { guiBGColor = GUI.backgroundColor; if (cg != null && cg.Count > 0) { GUI.backgroundColor = StylesUI.borderColor; } else { GUI.backgroundColor = Color.clear; } if (GUI.Button(rect, "")) { onClick(); } GUI.backgroundColor = guiBGColor; if (cg.Count > 0) { rect.width -= 2; rect.height -= 2; rect.x += 1; rect.y += 1; if (cg.Count == 1) { EditorGUI.DrawRect(rect, cg[0].color); } else { Rect r = rect; r.width = r.width * 0.7f; EditorGUI.DrawRect(r, cg[0].color); r.x += r.width; r.width = rect.width * 0.3f; r.width = r.width / (cg.Count - 1); for (int i = 1; i < cg.Count; i++) { EditorGUI.DrawRect(r, cg[i].color); r.x += r.width; } } } GUIStyle textStyle = StylesUI.ColoredLabel; if (cg.Count > 0) { if (EditorHelper.IsColorDark(cg[0].color)) { textStyle.normal.textColor = Color.white; } else { textStyle.normal.textColor = Color.black; } } else { textStyle.normal.textColor = StylesUI.CenteredLabel.normal.textColor; } rect.width *= 0.7f; rect.x += 5; EditorGUI.LabelField(rect, cg.name, textStyle); GUI.color = guiColor; }