From 992dfed278d803b6b9a08074979a1546947270b4 Mon Sep 17 00:00:00 2001 From: Michaelwolf95 Date: Thu, 19 Sep 2019 11:41:13 -0700 Subject: [PATCH] Fix for BlockInspector Crash On some newer versions of Unity, the BlockInspector will crash whenever the user selects a block in the flowchart window. The inspector window will not populate, and the console will throw null reference errors every editor frame as long as the block is selected. This is due to `activeBlockEditor` never getting instantiated properly. I suspect that this is due to recent API changes that made `Editor.CreateEditor(block)` create a generic Editor object, instead of a BlockEditor. Since the object is not actually the extended type, the reference becomes null after being cast using `as`. This overload parameter ensures that the object is instantiated using the correct type. This fix should work for all versions, as it appears to have been an API option since at least Unity 5.2 Tested on Unity 2018.0.1f1 and 2019.2.1f1 --- Assets/Fungus/Scripts/Editor/BlockInspector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Fungus/Scripts/Editor/BlockInspector.cs b/Assets/Fungus/Scripts/Editor/BlockInspector.cs index 1ef5a062..fc064c3b 100644 --- a/Assets/Fungus/Scripts/Editor/BlockInspector.cs +++ b/Assets/Fungus/Scripts/Editor/BlockInspector.cs @@ -97,7 +97,7 @@ namespace Fungus.EditorUtils !block.Equals(activeBlockEditor.target)) { DestroyImmediate(activeBlockEditor); - activeBlockEditor = Editor.CreateEditor(block) as BlockEditor; + activeBlockEditor = Editor.CreateEditor(block, typeof(BlockEditor)) as BlockEditor; } UpdateWindowHeight();