Browse Source

Fix null reference exception when spawning Fungus objects in Unity 5.1

master
chrisgregan 10 years ago
parent
commit
5d9353ea75
  1. 7
      Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs

7
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;
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;

Loading…
Cancel
Save