Transfer ownership OnApplicationPause in Unity

Options
I have one network scene game object that I can transfer the ownership of. Whoever is the owner of this object, which I check with photonView.isMine, has the control over the UI of the game (it's a turn-based card game). Everything works fine and as expected except in some edge cases. For example, I want to gracefully handle ReconnectAndRejoin() on mobile devices. Right now, if the application loses focus I call Photon.Disconnect() and I call ReconnectAndRejoin() after application resumes, which works fine. The problem is, if I am the owner of this Photon game object and my application loses focus (pauses by going into the background), how can I ensure that the ownership is transferred to someone else before my application disconnect and pauses? A coroutine wouldn't work because everything gets paused.
Any suggestions? Any help would be greatly appreciated.

Comments

  • sci_prog
    Options
    I guess a better question is, can cache OwnershipTransfer Events? Or should I Raise my own PunEvent.OwnershipTransfer with cache enabled and then listen for it OnEvent?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @sci_prog,

    Thank you for choosing Photon and sorry for the delay on this one!

    You need to trigger the ownership request and then send it right away in OnApplicationPause(true) as explained here.