fixing MissingReferenceException (#1624)

This commit is contained in:
James Frowen 2020-03-30 02:39:18 +01:00 committed by GitHub
parent deb286f0c2
commit dcb618bfd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,7 +74,8 @@ public override GUIContent GetPreviewTitle()
public override bool HasPreviewGUI()
{
return target is GameObject gameObject && gameObject.GetComponent<NetworkIdentity>() != null;
// need to check if target is null to stop MissingReferenceException
return target != null && target is GameObject gameObject && gameObject.GetComponent<NetworkIdentity>() != null;
}
public override void OnPreviewGUI(Rect r, GUIStyle background)