InvalidCastException in PhotonViewInspector.cs:32

Options

Hi!

Since PUN2 version 2.40 I'm getting the following exception a lot.

InvalidCastException: Specified cast is not valid.

Photon.Pun.PhotonViewInspector.OnEnable () (at Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonViewInspector.cs:32)

Is that something I could circumvent? Because it's inside an Editor Script, only: Will it break anything? So far I didn't notice anything not working in my game.

Thanks

Rene

Answers

  • Nyte
    Options

    Hey @rneumann

    I've been also getting some errors after upgrading PUN2 to 2.40. It's not the same but every time I click on an object which as any photon componenet, eg photonView I get these errors

    Instance of PhotonViewInspector couldn't be created. The script class needs to derive from ScriptableObject and be placed in the Assets/Editor folder.

    And same for others like

    Instance of PhotonTransformViewEditor couldn't be created. The script class needs to derive from ScriptableObject and be placed in the Assets/Editor folder.

    And it hasn't been affecting my game either, I'd assume it's a bug.

  • Tobias
    Options

    This .. sounds like an issue with Unity.

    We use this: PhotonViewInspector : Editor and the Editor class is inheriting from ScriptableObject. So unless I miss something essential, this should work (and does in many many Editor versions).

    Which Editor versions do you use?

    If this fails, the Editor scripts will fail to assign needed values for PhotonViews, etc.

  • rneumann
    Options

    My error message seems different than the one from @Nyte - I only get the InvalidCastException. However, I am using PUN2 2.40 and Unity 2020.3.23f1.