Unable to enter play mode in the Unity with PhotonNetwork.NetworkingClient = null

Options
My game works once build and run, but I'm unable to start the game when it's run from Unity using the play button. I'm getting the following error:

```
NullReferenceException: Object reference not set to an instance of an object
Photon.Pun.Simple.Internal.TickManager.Bootstrap () (at Assets/Photon/Simple/Core/TickManager/TickManager.cs:32)
```

When the scene is loaded, I call `PhotonNetwork.ConnectUsingSettings()` but it seems that the error above is happening earlier.

Comments

  • emotitron
    Options

    Be sure to have the latest pun2, this issue should be resolved. Let us know if it is not.

  • mastayoda
    Options
    emotitron wrote: »
    Be sure to have the latest pun2, this issue should be resolved. Let us know if it is not.

    I'm on 2.26.1, released Dec 15th, 2020, and also on the latest Unity 2020.2.0f1. The error is still happening. Did I miss something?
  • emotitron
    Options

    You may have found an edge case we haven't seen yet. You are using a Unity beta so something may have just changed. Are you on Discord? I can try replicating the issue if I can get more info.

  • mastayoda
    Options
    I have discord but I'm not on PhotonEngine, please provide me with the link and I'll be happy to join and share my screen or help with troubleshooting
  • emotitron
    Options

    https://discord.gg/egaRfd8 is our discord server.

  • mastayoda
    Options
    After a quick help from @emotitron, a missing change was discovered. In `TickManager` class `Bootstrap` method (line 28) change from:

    `[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]`

    to

    `[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]`

    At some point, this change will be a part of the PUN2 library
  • emotitron
    Options
    The issue we are seeing is that this has been patched, but some Unity versions seem to not be importing the latest Pun2 in the Package Manager. It looks like you are importing Pun2 v2.26.1 but it is actually not updating and is using an older version.

    This appears to be a problem with Unity 2020.2 currently, and I don't have an answer yet on how to force Unity to update the package.

    In the meantime, the fix above should get the errors to vanish and allow you to use Simple.