void DrawLegend() { List <Rect> legendRects = new List <Rect>(); List <AudioCurveWrapper> curves = GetShownAudioCurves(); Rect legendRect = GUILayoutUtility.GetRect(10, 40 * EditorGUIUtility.pixelsPerPoint); legendRect.x += 4 + EditorGUI.indent; legendRect.width -= 8 + EditorGUI.indent; // Graph's position acts as reference for Legends legendRect.y = m_CurveEditor.rect.y + m_CurveEditor.rect.height + 20; int width = Mathf.Min(75, Mathf.FloorToInt(legendRect.width / curves.Count)); for (int i = 0; i < curves.Count; i++) { legendRects.Add(new Rect(legendRect.x + width * i, legendRect.y, width, legendRect.height)); } bool resetSelections = false; if (curves.Count != m_SelectedCurves.Length) { m_SelectedCurves = new bool[curves.Count]; resetSelections = true; } if (EditorGUIExt.DragSelection(legendRects.ToArray(), ref m_SelectedCurves, GUIStyle.none) || resetSelections) { // If none are selected, select all bool someSelected = false; for (int i = 0; i < curves.Count; i++) { if (m_SelectedCurves[i]) { someSelected = true; } } if (!someSelected) { for (int i = 0; i < curves.Count; i++) { m_SelectedCurves[i] = true; } } SyncShownCurvesToLegend(curves); } for (int i = 0; i < curves.Count; i++) { EditorGUI.DrawLegend(legendRects[i], curves[i].color, curves[i].legend.text, m_SelectedCurves[i]); if (curves[i].curveProp.hasMultipleDifferentValues) { GUI.Button(new Rect(legendRects[i].x, legendRects[i].y + 20, legendRects[i].width, 20), "Different"); } } }
private void DrawLegend() { List <Rect> list = new List <Rect>(); List <AudioCurveWrapper> shownAudioCurves = this.GetShownAudioCurves(); Rect rect = GUILayoutUtility.GetRect((float)10f, (float)20f); rect.x += 4f + EditorGUI.indent; rect.width -= 8f + EditorGUI.indent; int num = Mathf.Min(0x4b, Mathf.FloorToInt(rect.width / ((float)shownAudioCurves.Count))); for (int i = 0; i < shownAudioCurves.Count; i++) { list.Add(new Rect(rect.x + (num * i), rect.y, (float)num, rect.height)); } bool flag = false; if (shownAudioCurves.Count != this.m_SelectedCurves.Length) { this.m_SelectedCurves = new bool[shownAudioCurves.Count]; flag = true; } if (EditorGUIExt.DragSelection(list.ToArray(), ref this.m_SelectedCurves, GUIStyle.none) || flag) { bool flag2 = false; for (int k = 0; k < shownAudioCurves.Count; k++) { if (this.m_SelectedCurves[k]) { flag2 = true; } } if (!flag2) { for (int m = 0; m < shownAudioCurves.Count; m++) { this.m_SelectedCurves[m] = true; } } this.SyncShownCurvesToLegend(shownAudioCurves); } for (int j = 0; j < shownAudioCurves.Count; j++) { EditorGUI.DrawLegend(list[j], shownAudioCurves[j].color, shownAudioCurves[j].legend.text, this.m_SelectedCurves[j]); if (shownAudioCurves[j].curveProp.hasMultipleDifferentValues) { Rect rect2 = list[j]; Rect rect3 = list[j]; Rect rect4 = list[j]; GUI.Button(new Rect(rect2.x, rect3.y + 20f, rect4.width, 20f), "Different"); } } }
private void DrawLegend() { List <Rect> rectList = new List <Rect>(); List <AudioSourceInspector.AudioCurveWrapper> shownAudioCurves = this.GetShownAudioCurves(); Rect rect = GUILayoutUtility.GetRect(10f, 20f); rect.x += 4f + EditorGUI.indent; rect.width -= 8f + EditorGUI.indent; int num = Mathf.Min(75, Mathf.FloorToInt(rect.width / (float)shownAudioCurves.Count)); for (int index = 0; index < shownAudioCurves.Count; ++index) { rectList.Add(new Rect(rect.x + (float)(num * index), rect.y, (float)num, rect.height)); } bool flag1 = false; if (shownAudioCurves.Count != this.m_SelectedCurves.Length) { this.m_SelectedCurves = new bool[shownAudioCurves.Count]; flag1 = true; } if (EditorGUIExt.DragSelection(rectList.ToArray(), ref this.m_SelectedCurves, GUIStyle.none) || flag1) { bool flag2 = false; for (int index = 0; index < shownAudioCurves.Count; ++index) { if (this.m_SelectedCurves[index]) { flag2 = true; } } if (!flag2) { for (int index = 0; index < shownAudioCurves.Count; ++index) { this.m_SelectedCurves[index] = true; } } this.SyncShownCurvesToLegend(shownAudioCurves); } for (int index = 0; index < shownAudioCurves.Count; ++index) { EditorGUI.DrawLegend(rectList[index], shownAudioCurves[index].color, shownAudioCurves[index].legend.text, this.m_SelectedCurves[index]); if (shownAudioCurves[index].curveProp.hasMultipleDifferentValues) { GUI.Button(new Rect(rectList[index].x, rectList[index].y + 20f, rectList[index].width, 20f), "Different"); } } }