Specified Cast is not valid after importing PUN 2+ into project

Options

This happens to me all of the time trying to import the PUN package into a project:

InvalidCastException: Specified cast is not valid.

Photon.Pun.PhotonNetwork.LoadOrCreateSettings (System.Boolean reload) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:3195)

Photon.Pun.PhotonNetwork.get_PhotonServerSettings () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:121)

Photon.Pun.PhotonEditor.OnProjectChanged () (at Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs:229)

Photon.Pun.PhotonEditor.OnDelayCall () (at Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs:210)

UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at <36f62d8e760b48f7af5d32916f997ce1>:0)

It doesn't create the server settings scriptable object and then PUN is unusable. Haven't been able to figure out why

Even copying the Photon folder over from another project apparently runs whatever this code is and actually deletes the server settings file so you end up with a broken photon install

Ideas?

Comments

  • Tobias
    Options

    This sounds like an issue we solved quite a while ago and never ran into since, so:

    Make sure you got the latest PUN 2 package from the store. In doubt, delete the Editor Asset Store cache and download again.

    Which Unity version is this?

    We only support the LTS versions of Unity. In doubt, get Unity 2020 LTS, create a new project and import into that, then upgrade with whatever version you want to use.