private void RangeField(ref float start, ref float end, ref int order) { var values = new int[] { Mathf.RoundToInt(-start), Mathf.RoundToInt(-end), order }; var labels = new GUIContent[] { new GUIContent("Start"), new GUIContent("End"), new GUIContent("Order") }; var position = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight); EditorGUI.BeginChangeCheck(); SpriteShapeEditorGUI.MultiDelayedIntField(position, labels, values, 40f); if (EditorGUI.EndChangeCheck()) { start = -1f * values[0]; end = -1f * values[1]; order = values[2]; } }
private List <Vector3> MultiVector2Field(GUIContent label, List <Vector3> values, float floatWidth) { float kSpacingSubLabel = 2.0f; float kMiniLabelW = 13; if (!values.Any()) { return(values); } Rect position = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight); int id = GUIUtility.GetControlID("Vector2Field".GetHashCode(), FocusType.Passive, position); position = SpriteShapeEditorGUI.MultiFieldPrefixLabel(position, id, label, 2); position.height = EditorGUIUtility.singleLineHeight; float w = (position.width - kSpacingSubLabel) / floatWidth; Rect nr = new Rect(position); nr.width = w; float t = EditorGUIUtility.labelWidth; int l = EditorGUI.indentLevel; EditorGUIUtility.labelWidth = kMiniLabelW; EditorGUI.indentLevel = 0; bool mixedValue = EditorGUI.showMixedValue; bool equalX = values.All(v => Mathf.Approximately(v.x, values.First().x)); bool equalY = values.All(v => Mathf.Approximately(v.y, values.First().y)); EditorGUI.showMixedValue = !equalX; EditorGUI.BeginChangeCheck(); float x = EditorGUI.FloatField(nr, Contents.xLabel, values[0].x); if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < values.Count; i++) { values[i] = new Vector3(x, values[i].y, values[i].z); } } nr.x += w + kSpacingSubLabel; EditorGUI.showMixedValue = !equalY; EditorGUI.BeginChangeCheck(); float y = EditorGUI.FloatField(nr, Contents.yLabel, values[0].y); if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < values.Count; i++) { values[i] = new Vector3(values[i].x, y, values[i].z); } } EditorGUI.showMixedValue = mixedValue; EditorGUIUtility.labelWidth = t; EditorGUI.indentLevel = l; return(values); }