Browse Source

Fix null reference exception when spawning Fungus objects in Unity 5.1

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

13
Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs

@ -26,11 +26,14 @@ namespace Fungus
GameObject go = PrefabUtility.InstantiatePrefab(prefab) as GameObject; GameObject go = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
PrefabUtility.DisconnectPrefabInstance(go); PrefabUtility.DisconnectPrefabInstance(go);
Camera sceneCam = SceneView.currentDrawingSceneView.camera; SceneView view = SceneView.currentDrawingSceneView;
if (view != null)
Vector3 pos = sceneCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 10f)); {
pos.z = 0f; Camera sceneCam = view.camera;
go.transform.position = pos; Vector3 pos = sceneCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 10f));
pos.z = 0f;
go.transform.position = pos;
}
Selection.activeGameObject = go; Selection.activeGameObject = go;

Loading…
Cancel
Save