From b0e7812054131d29f99fd44d67f1e8d02cc7f178 Mon Sep 17 00:00:00 2001 From: gwaredd Date: Sat, 9 Nov 2019 18:29:42 +0000 Subject: [PATCH] fix for scrolling in 2019 --- Editor/Scripts/MarkdownViewer.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Editor/Scripts/MarkdownViewer.cs b/Editor/Scripts/MarkdownViewer.cs index c42277a..41d47dd 100644 --- a/Editor/Scripts/MarkdownViewer.cs +++ b/Editor/Scripts/MarkdownViewer.cs @@ -74,12 +74,26 @@ Layout ParseDocument() //------------------------------------------------------------------------------ +#if UNITY_2019 + private float mHeight = 1.0f; +#endif + protected Rect GetEditorRect() { #if UNITY_2019 - var height = Screen.height - 138.0f; // TODO: need better way of getting height! - GUILayout.Space( height ); - return new Rect( 0.0f, 4.0f, EditorGUIUtility.currentViewWidth, height ); + + // calculate working space + if( Event.current.type == EventType.Layout ) + { + var offset = 32.0f + 96.0f + 4.0f; // tab height + asset labels height + offset + mHeight = ( Screen.height - offset ) / 1.5115f; + } + + // reserve space (we are going to paint on it directly) + GUILayout.Space( mHeight ); + + // return working rect + return new Rect( 0.0f, 4.0f, EditorGUIUtility.currentViewWidth, mHeight ); #else GUILayout.FlexibleSpace(); var rectContainer = GUILayoutUtility.GetLastRect();