@ -103,10 +103,6 @@ namespace Fungus.EditorUtils
float width = EditorGUIUtility . currentViewWidth ;
float height = windowHeight ;
// Using a custom rect area to get the correct 5px indent for the scroll views
Rect blockRect = new Rect ( 5 , topPanelHeight , width - 5 , height + 1 0 ) ;
GUILayout . BeginArea ( blockRect ) ;
blockScrollPos = GUILayout . BeginScrollView ( blockScrollPos , GUILayout . Height ( flowchart . BlockViewHeight ) ) ;
activeBlockEditor . DrawBlockGUI ( flowchart ) ;
GUILayout . EndScrollView ( ) ;
@ -121,7 +117,6 @@ namespace Fungus.EditorUtils
inspectCommand ! = null & &
! inspectCommand . ParentBlock . Equals ( block ) )
{
GUILayout . EndArea ( ) ;
Repaint ( ) ;
return ;
}
@ -143,6 +138,9 @@ namespace Fungus.EditorUtils
/// </summary>
protected void UpdateWindowHeight ( )
{
#if UNITY_2019_1_OR_NEWER
windowHeight = Screen . height * EditorGUIUtility . pixelsPerPoint ;
# else
EditorGUILayout . BeginVertical ( ) ;
GUILayout . FlexibleSpace ( ) ;
EditorGUILayout . EndVertical ( ) ;
@ -151,13 +149,14 @@ namespace Fungus.EditorUtils
{
windowHeight = tempRect . height ;
}
# endif
}
public void DrawCommandUI ( Flowchart flowchart , Command inspectCommand )
{
ResizeScrollView ( flowchart ) ;
GUILayout . Space ( 7 ) ;
Editor GUILayout. Space ( ) ;
activeBlockEditor . DrawButtonToolbar ( ) ;
@ -191,11 +190,9 @@ namespace Fungus.EditorUtils
GUILayout . EndScrollView ( ) ;
GUILayout . EndArea ( ) ;
// Draw the resize bar after everything else has finished drawing
// This is mainly to avoid incorrect indenting.
Rect resizeRect = new Rect ( 0 , topPanelHeight + flowchart . BlockViewHeight + 1 , Screen . w idth , 4f ) ;
Rect resizeRect = new Rect ( 0 , flowchart . BlockViewHeight , EditorGUIUtility . currentViewW idth, 4f ) ;
GUI . color = new Color ( 0.64f , 0.64f , 0.64f ) ;
GUI . DrawTexture ( resizeRect , EditorGUIUtility . whiteTexture ) ;
resizeRect . height = 1 ;
@ -210,16 +207,19 @@ namespace Fungus.EditorUtils
private void ResizeScrollView ( Flowchart flowchart )
{
Rect cursorChangeRect = new Rect ( 0 , flowchart . BlockViewHeight + 1 , Screen . w idth, 4f ) ;
Rect cursorChangeRect = new Rect ( 0 , flowchart . BlockViewHeight + 1 , EditorGUIUtility . currentViewW idth, 4f ) ;
EditorGUIUtility . AddCursorRect ( cursorChangeRect , MouseCursor . ResizeVertical ) ;
if ( Event . current . type = = EventType . MouseDown & & cursorChangeRect . Contains ( Event . current . mousePosition ) )
if ( cursorChangeRect . Contains ( Event . current . mousePosition ) )
{
resize = true ;
if ( Event . current . type = = EventType . MouseDown )
{
resize = true ;
}
}
if ( resize )
if ( resize & & Event . current . type = = EventType . Repaint )
{
Undo . RecordObject ( flowchart , "Resize view" ) ;
flowchart . BlockViewHeight = Event . current . mousePosition . y ;
@ -231,7 +231,7 @@ namespace Fungus.EditorUtils
// This isn't standard Unity UI behavior but it is robust and safe.
if ( resize & & Event . current . type = = EventType . MouseDrag )
{
Rect windowRect = new Rect ( 0 , 0 , Screen . width , Screen . h eight) ;
Rect windowRect = new Rect ( 0 , 0 , EditorGUIUtility . currentViewWidth , windowH eight) ;
if ( ! windowRect . Contains ( Event . current . mousePosition ) )
{
resize = false ;
@ -259,7 +259,7 @@ namespace Fungus.EditorUtils
// Make sure block view is always clamped to visible area
float height = flowchart . BlockViewHeight ;
height = Mathf . Max ( 2 0 0 , height ) ;
height = Mathf . Min ( Screen . h eight - 2 0 0 , height ) ;
height = Mathf . Min ( windowH eight - 2 0 0 , height ) ;
flowchart . BlockViewHeight = height ;
}