How do I prevent the player gameobject from being destroyed while I'm debugging

Options
When I join the room I create a GameObject for the local player using PhotonNetwork.Instantiate.
After that I connect the visual studio debugger to unity and stop at a breakpoint to debug some code.
If I stay stopped at that breakpoint for long enough, when I allow unity to resume the player GameObject gets destroyed (presumably by photon, but there is no call stack to trace to the OnDestroy function of a script on that object).
Am I correct in assuming that Photon has destroyed the gameobject? How can I stop it doing that? It makes is really hard to debug stuff when the player keeps getting destroyed...

Answers

  • KamoBang
    Options
    I had exactly that too. Your application freezing when you break at a point which could cause that photon will destory the player because of time out or something else. That's my thereory.
  • tdaffin
    Options
    Yeah, that was what I was thinking -- some kind of network timeout.. maybe I should google that.
  • tdaffin
    Options
    Ok, I found this for timeouts while loading scenes:
    "To keep the connection while loading scenes, you should set PhotonNetwork.IsMessageQueueRunning = false."
    It was here: https://doc.photonengine.com/en/realtime/current/reference/client-connection-handling
    Not sure if I can call that when the debugger breaks though...
  • tdaffin
    Options
    Yeah, timeout for sure -- I have a 'NetworkManager' class that derives from PunBehavior.
    I added an override for OnConnectionFail and when I restart unity after pausing at a breakpoint I get this call stack:
    NetworkManager.OnConnectionFail DisconnectByServerTimeout
    UnityEngine.Debug:Log(Object)
    Assets.Scripts.Network.NetworkManager:OnConnectionFail(DisconnectCause) (at Assets/Scripts/Network/NetworkManager.cs:165)
    UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
    NetworkingPeer:SendMonoMessage(PhotonNetworkingMessage, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2113)
    NetworkingPeer:OnStatusChanged(StatusCode) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1710)
    ExitGames.Client.Photon.EnetPeer:ExecuteCommand(NCommand)
    ExitGames.Client.Photon.<>c__DisplayClass11:b__f()
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:125)
  • tdaffin
    Options
    So, for sure if I set 'PhotonNetwork.isMessageQueueRunning = false;' before breaking into the debugger the timeout does not occur and the GameObject does not get destroyed.
    Not ideal but enough to stop me completely tearing my hair out for now...
    So, PUN developers how about being able to tell PUN *not* to destroy gameobjects while broken in the debugger? Maybe just set 'IsMessageQueueRunning = false' for us when the breakpoint is hit and putting it back to true when we continue?