Cannot Switch To Offline Mode

Options
i'm using PhotonNetwork.offlineMode to share code between the single-player and the multi-player games. the game works fine if i run it in offline mode, and it works fine if i run it in online mode. however, whenever i try to switch back to offline mode after an online match, it wouldn't allow me to PhotonNetwork.Instantiate anything. i'd very much appreciate it if someone could have a look at what i'm doing wrong:

[code2=csharp]if (!PhotonNetwork.offlineMode) {
// disconnect everything and go into offline mode.
Debug.Log ("switching to offline mode.");
if (PhotonNetwork.connected) {
Debug.Log ("disconnecting from network.");
PhotonNetwork.Disconnect ();
while (PhotonNetwork.connected) {
yield return null;
}
}
PhotonNetwork.offlineMode = true;
}
if (PhotonNetwork.room == null) {
// enter offline room.
Debug.Log ("creating offline room.");
PhotonNetwork.CreateRoom (null, false, false, 1);
} else {
Debug.Log ("already in room " + PhotonNetwork.room.name);
OnJoinedRoom ();
}[/code2]

i would be able to enter an "OfflineRoom", and everything looks fine, except that i cannot properly instantiate anything, and i get a null ref error if i try to get owners of photonviews... please help! :geek:

Comments

  • Leepo
    Options
    I've tested the same situation in the PUN "worker demo" and that seems to instantiate fine, chat also works.
    So we must be doing something different. What nullreff are you getting?
  • i have built a small prototype to demonstrate the issue. i've uploaded it to:
    https://bitbucket.org/hamletarcher/phot ... mode-test/
      open the scene "OfflineModeTest" press the "spawn prefab" button --> prefabs are spawned correctly, and RPCs are called correctly. press load offline level --> press the "spawn prefab" button --> things are fine. press load online level --> press the "spawn prefab" button --> still fine.
    press load offline level --> now the photon player id become -1, and all the photonView ids become -999, -998 etc.
    i get a null ref if i try to get photonView.owner, and all RPCs cease to work. :shock: