Exception in PhotonView

Options
I ran into this today. There is probably something wrong my setup, but still, it shouldn't cause exceptions. I'm using PUN 2.9


(Filename: C:/Projects/IncidentCommander/IC_Unity/Incident Commander/Assets/Plugins/Photon/PhotonUnityNetworking/Code/PhotonView.cs Line: 367)

NullReferenceException: Object reference not set to an instance of an object
at Photon.Pun.PhotonView.SerializeComponent (UnityEngine.Component component, Photon.Pun.PhotonStream stream, PhotonMessageInfo info) [0x0003b] in C:\Projects\IncidentCommander\IC_Unity\Incident Commander\Assets\Plugins\Photon\PhotonUnityNetworking\Code\PhotonView.cs:367
at Photon.Pun.PhotonView.SerializeView (Photon.Pun.PhotonStream stream, PhotonMessageInfo info) [0x00035] in C:\Projects\IncidentCommander\IC_Unity\Incident Commander\Assets\Plugins\Photon\PhotonUnityNetworking\Code\PhotonView.cs:329
at Photon.Pun.PhotonNetwork.OnSerializeWrite (Photon.Pun.PhotonView view) [0x00085] in C:\Projects\IncidentCommander\IC_Unity\Incident Commander\Assets\Plugins\Photon\PhotonUnityNetworking\Code\PhotonNetworkPart.cs:1520
at Photon.Pun.PhotonNetwork.RunViewUpdate () [0x000a9] in C:\Projects\IncidentCommander\IC_Unity\Incident Commander\Assets\Plugins\Photon\PhotonUnityNetworking\Code\PhotonNetworkPart.cs:1449
at Photon.Pun.PhotonHandler.LateUpdate () [0x00025] in C:\Projects\IncidentCommander\IC_Unity\Incident Commander\Assets\Plugins\Photon\PhotonUnityNetworking\Code\PhotonHandler.cs:132



Comments

  • Tobias
    Options
    You are right, normally, there is no exception at this place.
    PUN 2 stores observed scripts as Component and casts those to IPunObservable (line 360). It seems the observed Component is null, which is the error in the logging.
    Please modify the logging to not log the component (which is null) but to log the object's name / ID to find which object causes this, so you could hunt down why the Component is null in the first place.

    The PhotonViewInspector in the Editor typically makes sure that observed components are actually IPunObservable and non-null. There are a few cases where this gets bypassed:
    Are you adding or removing observed Components of PhotonViews at runtime?
    Maybe you added a IPunObservable Component to the PhotonView observed list but then modified the code and removed IPunObservable?