How do you initialise photonView in a Photon.MonoBehaviour?

Options
In an object derived from Photon.Monobehaviour I'm trying to call photonView.RPC(), but photonView is null. This is after Start() has been called. How do I initialise photonView?

Comments

  • Tobias
    Options
    The script must be on a GameObject which in turn also has a PhotonView. Else, the photonView will be null.
    Please verify you got a PV on that GO.
  • Chubysnow
    Options
    If the object has multiple scripts that use Photon.MonoBehaviour, does it need more than one photonView?
  • Tobias
    Options
    No. Multiple views could help separate stuff but in general you only need one PV to identify the GO.
  • Chubysnow
    Options
    If each class sends RPCs, do they need PhotonViews or is that only if they use OnPhotonViewSerialize.
  • Tobias
    Options
    You can call RPC from more than just one class of course.
    If you want to call multiple implementations of OnPhotonViewSerialize (in many scripts) you can use more than one PhotonView or implement one OnPhotonViewSerialize to call the others. You just have to make sure the receiver knows how to read what you send.

    Basically, you could totally ignore PhotonViews in Photon and come up with your own events, IDs, etc. PhotonViews just make it simpler.