/// <inheritdoc /> public override bool DrawBody(Rect position) { if (ViewingYaml()) { var contentRect = position; contentRect.x = 0f; contentRect.y = 0f; contentRect.height = yamlContentHeight; if (yamlViewHasScrollBar) { contentRect.width -= DrawGUI.ScrollBarWidth; } var viewportRect = position; viewportRect.height = yamlViewportHeight; DrawGUI.BeginScrollView(viewportRect, contentRect, ref yamlViewScrollPos); { var style = InspectorPreferences.Styles.formattedText; var linePosition = contentRect; linePosition.height = DrawGUI.SingleLineHeight; int firstIndex = Mathf.FloorToInt(yamlViewScrollPos.y / DrawGUI.SingleLineHeight); int lastIndex = firstIndex + Mathf.FloorToInt(yamlViewportHeight / DrawGUI.SingleLineHeight); int lineCount = yaml.LineCount; if (lastIndex >= lineCount) { lastIndex = lineCount - 1; } linePosition.y = yamlViewScrollPos.y - yamlViewScrollPos.y % DrawGUI.SingleLineHeight; for (int n = firstIndex; n <= lastIndex; n++) { EditorGUI.SelectableLabel(linePosition, yaml[n], style); linePosition.y += DrawGUI.SingleLineHeight; } } DrawGUI.EndScrollView(); return(false); } return(base.DrawBody(position)); }
/// <inheritdoc/> public override bool DrawBody(Rect position) { if (!HasSideBar) { return(base.DrawBody(position)); } bool dirty = DrawSideBar(sideBarPosition); if (position.width < sideBarWidth + PrefixLabelWidth + 5f) { return(dirty); } var viewRect = position; viewRect.height = ContentHeight; viewRect.x = 0f; viewRect.y = 0f; #if DEV_MODE && PI_ASSERTATIONS Debug.Assert(viewRect.height > 0f); #endif position.height = DrawGUI.InspectorHeight - Inspector.ToolbarHeight - HeaderHeight; bool hasScrollBar = viewRect.height > position.height; if (hasScrollBar) { viewRect.width -= DrawGUI.ScrollBarWidth; } DrawGUI.BeginScrollView(position, viewRect, ref scrollPosition); { if (DrawBodyMultiRow(viewRect)) { dirty = true; } } DrawGUI.EndScrollView(); return(dirty); }