RemovePhotonView

Hello,

I'm using a new version of Photon within Unity and it has broken functionality I think. Originally, when my players joined/left rooms in Unity, they were automatically destroyed on all clients; now, they are not. I think I have traced it down to this...

Previous version of PhotonView.cs:

public void OnDestroy()
{
PhotonNetwork.networkingPeer.RemovePhotonView(this);


The new version of PhotonView.cs does not have this call (RemovePhotonView) any longer. And now I am receiving this message:

OnDestroy for PhotonView View (0)1001 on c but GO is still in instantiatedObjects. instantiationId: 1001. Use PhotonNetwork.Destroy(). Identical with this: True PN.Destroyed called for this PV: True
UnityEngine.Debug:LogWarning(Object)
PhotonView:OnDestroy() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/Extension/PhotonView.cs:208)

I have been at this for about two days now and am getting nowhere.

Thank you,
Caesar

Comments

  • We recently cleaned up the internal workflow to remove/clean objects but the goal was to keep the usage the same.
    Maybe this didn't work out in your use case.

    Check if you use PhotonNetwork.Destroy for any GO with a PhotonView on it.


    Instead of RemovePhotonView, we now have this:
    [code2=csharp]if (!this.destroyedByPhotonNetworkOrQuit)
    {
    PhotonNetwork.networkingPeer.LocalCleanPhotonView(this);
    }[/code2]
    It should locally clean up things if the object wasn't destroyed explicitly with PhotonNetwork.Destroy.

    I am not sure if you actually see a misbehaviour or issue. If not, I think you could ignore the log.

    The comment in that section says: "Unity destroys GOs and PVs at the end of a frame. In worst case, a instantiate created a new view with the same id. Let's compare the associated GameObject."
    Based on that, maybe the check around the log should be inverted to: if (!instanceIsThisOne). Then you might not get the log, as we detect the GO was destroyed.

    I could use some info by you: Do you really get an issue? Do you use PN.Destroy properly? How do you cause the issue?