// InspectorGUI support internal void DrawInspector(Action <Rect, int, Color> drawer) { var h = 18f; var o = 5f; var oy = 2f; var ratio = 0.75f; var mRect = GUILayoutUtility.GetRect(0, Screen.width, h, h); var mWidth = mRect.width; if (drawer != null) { mRect.width *= ratio; drawer(mRect, -1, Color.black); mRect.x += ratio * mWidth + o; mRect.width = mWidth * (1 - ratio) - o; } var newMode = (h2_ColorMode)EditorGUI.EnumPopup(mRect, mode); if (newMode != mode) { mode = newMode; resize((int)mode); } for (var i = 0; i < COLOR_NAMES.Length; i++) { //swap index var idx = COLOR_INDEXES[i]; var rect = GUILayoutUtility.GetRect(0, Screen.width, h, h); var r = new Rect(rect.x, rect.y, rect.width * ratio, h); h2_GUI.SolidColor(r, BG_COLOR[idx]); r.x += o; r.y += oy; h2_GUI.LabelColor(r, COLOR_NAMES[i], LABEL_COLOR[idx]); r.x -= o; var color = colors[idx % (int)mode]; if (drawer != null) { drawer(r, idx, color); } r.x += ratio * rect.width + o; r.width = (1 - ratio) * rect.width - o; if (idx < (int)mode) { DrawColorPicker(r, ref color); colors[idx] = color; } } }
public h2_Color(Color[] pcolors) { mode = (h2_ColorMode)pcolors.Length; colors = new List <Color>(); colors.AddRange(pcolors); }