fix NullReferenceExceptions with focused boids during maximized play

during maximized play, focusing a Boid would cause NullReferenceExceptions as there was no active SceneView in the Unity Editor. Thus, without a SceneView, attempting to acquire one would return null. No test was done prior to acting on the Nullable return.
This commit is contained in:
Xevion
2020-11-02 12:15:57 -06:00
parent fe79a5ff5e
commit 930b1aec46

View File

@@ -75,7 +75,7 @@ public class BoidController : MonoBehaviour {
// Focus on the boid in scene view when one is focused // Focus on the boid in scene view when one is focused
#if UNITY_EDITOR #if UNITY_EDITOR
if(focusedBoid != null) if(focusedBoid != null && SceneView.lastActiveSceneView != null)
SceneView.lastActiveSceneView.LookAtDirect(focusedBoid.transform.position, Quaternion.identity); SceneView.lastActiveSceneView.LookAtDirect(focusedBoid.transform.position, Quaternion.identity);
#endif #endif
} }