Can Photon cause a gameobject to get disabled?

Options
- I am seeing some very strange behavior in Unity. When I join a room, sometimes one of the gameobjects with a Punbehaviour attached gets disabled. This only happens when I join an existing room (and that too not always) but never when I create a room.
- I have checked my code thoroughly using breakpoints and debug logs and I am sure that my code is not disabling that gameobject.
- Is there any precedence of Photon showing this kind of behavior, i.e. disabling gameobjects?
- Just to give an idea of the setup: I have two punbehaviors in the scene attached to two different gameobjects.
- Both of them are subscribed to some of the usual Photon callbacks like OnJoinedRoom, OnPhotonPlayerConnected etc. Could this be causing the problem?
- I am using PUN 1.0 and Unity 2018.3.0

I can change the architecture to work with just one Punbehaviour and see if that fixes the problem but it's going to take significant effort. If anybody can confirm encountering this kind of bug before then I would feel a lot better changing up the architecture.

Thanks.

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @blender,

    Thank you for choosing Photon!

    If a GameObject has a PunBehaviour then there is a high chance it has a PhotonView and is network instantiated at runtime.
    Those network objects could be cleaned up automatically by PUN yes.
  • blender
    Options
    hi @JohnTube

    Both the objects are already present in the scene, they are not network instantiated. Neither of them has a PhotonView component. One of the objects is disabled in the scene by default and is enabled dynamically based on user input.

    What triggers this 'automatic clean up' by PUN?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @blender,

    If there is no PhotonView then PUN will not delete the GameObject.

    PUN automatically cleans up GameObject instantiated using PhotonNetwork.Instantiate calls when a remote owner leaves or local player disconnects.
  • blender
    Options
    Never mind, I think the behaviour that I was seeing was due to some issue with automatic scene syncing. I am now syncing the scene manually and the issue seems to have gone away.

    Thank you for your input :smile: