From 0e82fa3b7575d10248231295e97f49dc75b38e4e Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Fri, 20 Sep 2019 19:33:03 +1000 Subject: [PATCH] Fallback for Command Search Popup height - Fixes a null ref caused changes in Unity Editor UI where EditorWindow.focusedWindow would be null --- Assets/Fungus/Scripts/Editor/BlockEditor.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Assets/Fungus/Scripts/Editor/BlockEditor.cs b/Assets/Fungus/Scripts/Editor/BlockEditor.cs index a097df7b..b8ed8714 100644 --- a/Assets/Fungus/Scripts/Editor/BlockEditor.cs +++ b/Assets/Fungus/Scripts/Editor/BlockEditor.cs @@ -319,9 +319,15 @@ namespace Fungus.EditorUtils // Add Button if (GUILayout.Button(addIcon)) { + //this may be less reliable for HDPI scaling but previous method using editor window height is now returning + // null in 2019.2 suspect ongoing ui changes, so default to screen.height and then attempt to get the better result + int h = Screen.height; + if (EditorWindow.focusedWindow != null) h = (int)EditorWindow.focusedWindow.position.height; + else if (EditorWindow.mouseOverWindow != null) h = (int)EditorWindow.mouseOverWindow.position.height; + CommandSelectorPopupWindowContent.ShowCommandMenu(lastCMDpopupPos, "", target as Block, (int)(EditorGUIUtility.currentViewWidth), - (int)(EditorWindow.focusedWindow.position.height - lastCMDpopupPos.y)); + (int)(h - lastCMDpopupPos.y)); } // Duplicate Button