How to maintain peer in Bootcamp Demo

thetnswe ✭✭
edited March 2011 in Photon Server
I've already looked at the codes for Bootcamp demo and it happens in one scene only . I am trying to seperate secens into Menu scene and Game Scene. I've got the connection part working during in the lobby menu. When I make the create game, it load and setup a new level. The problem comes up in there. The Photon class I created in menu becomes null and not accessible from game anymore. I tried to store it in the static varibles and even with static varible, it seems to get destroyed before getting into game so the game doesn't know about connection anymore..

How can I maintain the photon and peer throughout all the scenes?


  • Tobias
    Hmmm, good question but I can't help. It's pretty Unity specific, so maybe you should also ask this in the Unity forum.
  • dragagon
    In your lobby scene you want to add something along the lines of DontDestroyOnLoad(connection); wherever your connection is. This will allow it to persist between scenes. the object passed in needs to be a game object holding your connection.
  • thetnswe
    I've tried DontDestroyOnLoad() function on my scripts and it doesn't work in scripts as it just work on the game objects.. i even tried to store my Photon Peer connection on the static variables and even that static variables get destroyed on the next level load..