public static DrawRectangle ( |
||
rect | /// The position and size of the rectangle. /// | |
color | Color | /// The color of the rectangle. /// |
리턴 | void |
/// <summary> /// Renders the entries. /// </summary> private void DrawEntries() { var rect = new Rect(this.headerWidth, 0.0f, 0.0f, this.entryRowHeight); foreach (var sourceName in TimelineLog.Sources.Keys.OfType <string>().OrderBy(s => s)) { var source = TimelineLog.Sources[sourceName] as TimelineLogSource; if (source.IsFolded) { continue; } GUI.color = this.bgColor1; var columnWidth = 100.0f; var width = Mathf.Max(this.canvasWidth, this.position.width); var count = width / columnWidth; for (var index = 0; index < count; index++) { var timeRect = new Rect(index * columnWidth, rect.y, 1.0f, this.rowHeight); EditorGUIEx.DrawRectangle(timeRect, this.bgColor1); timeRect.x += 2.0f; timeRect.width = columnWidth; GUI.Label(timeRect, ((index * columnWidth) / this.timeScale) + "s"); } rect.y += this.rowHeight + (this.rowHeight - this.entryRowHeight) * 0.5f; GUI.color = Color.white; foreach (var categoryName in source.Categories.Keys.OfType <string>().OrderBy(s => s)) { var entries = source.Categories[categoryName] as LinkedList <TimelineLogEntry>; foreach (var entry in entries) { var delta = entry.End - entry.Start; var content = new GUIContent( entry.Message, entry.Message + Environment.NewLine + "Start: " + entry.Start + "s" + Environment.NewLine + "End: " + entry.End + "s" + Environment.NewLine + "Delta: " + delta + "s" ); rect.x = entry.Start * this.timeScale; rect.width = this.entryStyle.fixedWidth = Mathf.Max(delta * this.timeScale, this.minEntryWidth) ; EditorGUIEx.DrawRectangle(rect, entry.Color); GUI.color = Color.white; GUI.Label(rect, content, this.entryStyle); } rect.y += this.rowHeight; } } }
/// <summary> /// Renders the background of the timeline. /// </summary> private void DrawBackground() { var rect = new Rect(0.0f, 0.0f, this.position.width - this.scrollbarWidth, this.rowHeight); foreach (var sourceName in TimelineLog.Sources.Keys.OfType <string>().OrderBy(s => s)) { // nothing to output here, but still increment y-axis rect.y += this.rowHeight; var source = TimelineLog.Sources[sourceName] as TimelineLogSource; if (source.IsFolded) { continue; } for (var index = 0; index < source.Categories.Count; index++) { var color = (rect.y % (this.rowHeight * 2.0f)) == 0.0f ? this.bgColor1 : this.bgColor2; EditorGUIEx.DrawRectangle(rect, color); rect.y += this.rowHeight; } } GUI.color = Color.white; }