public int GetEntryHeight(Log.Entry entry, bool recursively = false) { int height = lineHeight; if (recursively && entry.subs != null && entry.guiExpanded) { foreach (Log.Entry sub in entry.subs) { height += GetEntryHeight(sub, true); } } return(height); }
public int DrawEntry(Rect rect, Log.Entry entry, bool recursively = false) /// returns the number of entries actually drawn { //line separator EditorGUI.DrawRect(new Rect(rect.x, rect.y, rect.width, 1), new Color(0.6f, 0.6f, 0.6f)); //what's written string name = entry.name; if (entry.startTicks != 0) { name += $" ({((entry.disposeTicks-entry.startTicks)/(float)System.TimeSpan.TicksPerMillisecond).ToString("0.0")} ms)"; } GUIContent content = new GUIContent(name, name); //label/foldout if (!recursively || entry.subs == null) { EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width, lineHeight), content, labelStyle); } else { entry.guiExpanded = EditorGUI.Foldout(new Rect(rect.x, rect.y, rect.width, lineHeight), entry.guiExpanded, content); } //subs int counter = 1; if (entry.guiExpanded && recursively && entry.subs != null) { foreach (Log.Entry sub in entry.subs) { counter += DrawEntry(new Rect(rect.x + 20, rect.y + counter * lineHeight, rect.width - 20, rect.y - lineHeight), sub, true); } } return(counter); }