From 5d9353ea75e0ddf6b57e35afc50234208d79f01c Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 17 Jun 2015 15:36:48 +0100 Subject: [PATCH] Fix null reference exception when spawning Fungus objects in Unity 5.1 --- .../Fungus/Flowchart/Editor/FlowchartMenuItems.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs b/Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs index 01b4ca9d..8c7d5189 100644 --- a/Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs +++ b/Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs @@ -26,11 +26,14 @@ namespace Fungus GameObject go = PrefabUtility.InstantiatePrefab(prefab) as GameObject; PrefabUtility.DisconnectPrefabInstance(go); - Camera sceneCam = SceneView.currentDrawingSceneView.camera; - - Vector3 pos = sceneCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 10f)); - pos.z = 0f; - go.transform.position = pos; + SceneView view = SceneView.currentDrawingSceneView; + if (view != null) + { + Camera sceneCam = view.camera; + Vector3 pos = sceneCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 10f)); + pos.z = 0f; + go.transform.position = pos; + } Selection.activeGameObject = go;