public static void ShowWindow() { window = GetWindow <AddSerieEditor>(); window.titleContent = new GUIContent("Add Serie"); window.minSize = new Vector2(350, window.minSize.y); window.Focus(); window.Show(); }
public static void ShowWindow() { serieName = "serie" + (chart.series.Count + 1); window = GetWindow <AddSerieEditor>(); window.titleContent = new GUIContent("Add Serie"); window.minSize = new Vector2(350, window.minSize.y); window.Focus(); window.Show(); }
public static void MakeList(ref Rect drawRect, ref float height, SerializedProperty listProp, bool showOrder = false, bool showSize = true) { EditorGUI.indentLevel++; var listSize = listProp.arraySize; var iconWidth = 14; var iconGap = 3f; if (showSize) { if (showOrder) { var temp = INDENT_WIDTH + GAP_WIDTH + iconGap; var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - iconWidth + 2, drawRect.height); var iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height); if (XChartsSettings.editorBlockEnable) { iconRect.x += BLOCK_WIDTH; } var oldColor = GUI.contentColor; GUI.contentColor = Color.black; if (GUI.Button(iconRect, Styles.iconAdd, Styles.invisibleButton)) { if (listProp.displayName.Equals("Series")) { AddSerieEditor.chart = listProp.serializedObject.targetObject as BaseChart; AddSerieEditor.ShowWindow(); } else { listProp.arraySize++; } } GUI.contentColor = oldColor; listSize = listProp.arraySize; listSize = EditorGUI.IntField(elementRect, "Size", listSize); } else { listSize = EditorGUI.IntField(drawRect, "Size", listSize); } if (listSize < 0) { listSize = 0; } drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; if (listSize != listProp.arraySize) { while (listSize > listProp.arraySize) { listProp.arraySize++; } while (listSize < listProp.arraySize) { listProp.arraySize--; } } } if (listSize > 30 && !XChartsSettings.editorShowAllListData) { SerializedProperty element; int num = listSize > 10 ? 10 : listSize; for (int i = 0; i < num; i++) { element = listProp.GetArrayElementAtIndex(i); EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + i)); drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; height += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; } if (num >= 10) { EditorGUI.LabelField(drawRect, "..."); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; element = listProp.GetArrayElementAtIndex(listSize - 1); EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + (listSize - 1))); drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; height += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; } } else { for (int i = 0; i < listProp.arraySize; i++) { SerializedProperty element = listProp.GetArrayElementAtIndex(i); if (showOrder) { var temp = INDENT_WIDTH + GAP_WIDTH + iconGap; var isSerie = "Serie".Equals(element.type); var elementRect = isSerie ? new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH - 2 * iconGap, drawRect.height) : new Rect(drawRect.x, drawRect.y, drawRect.width - 3 * iconWidth, drawRect.height); EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i)); var iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); if (XChartsSettings.editorBlockEnable) { iconRect.x += BLOCK_WIDTH; } var oldColor = GUI.contentColor; GUI.contentColor = Color.black; if (GUI.Button(iconRect, Styles.iconUp, Styles.invisibleButton)) { if (i > 0) { listProp.MoveArrayElement(i, i - 1); } } iconRect = new Rect(drawRect.width - 2 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); if (XChartsSettings.editorBlockEnable) { iconRect.x += BLOCK_WIDTH; } if (GUI.Button(iconRect, Styles.iconDown, Styles.invisibleButton)) { if (i < listProp.arraySize - 1) { listProp.MoveArrayElement(i, i + 1); } } iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height); if (XChartsSettings.editorBlockEnable) { iconRect.x += BLOCK_WIDTH; } if (GUI.Button(iconRect, Styles.iconRemove, Styles.invisibleButton)) { if (i < listProp.arraySize && i >= 0) { listProp.DeleteArrayElementAtIndex(i); } } else { drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; height += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; } GUI.contentColor = oldColor; } else { EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + i)); drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; height += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; } } } EditorGUI.indentLevel--; }