"RPC" not found

I've changed one of my existing scripts from MonoBehavior to Photon.MonoBehavior and added an [RPC] void function () to it, but when I try to call that from another script, it gives me this error:

Type `NumberManager' does not contain a definition for `RPC' and no extension method `RPC' of type `NumberManager' could be found (are you missing a using directive or an assembly reference?)

Comments

  • Alternatively, I've now called photonView.RPC("myFunction",args[]) and it works fine, BUT I'm not able to call functions with a return value. So, now my issue is that I need to instance an object via RPC, then modify that object, but I can't get a reference to it because the instancing of the object happens inside an RPC script which must be "void".
  • I don't know what you want to achieve but the RPC is going to be called on the remote clients as well as on the originating one (depending on the target parameters).
    Even if we sent back a return value, how would you handle it when multiple other players are sending their results?

    You need to send back another RPC in worst case.
    In best case, you might also stick to PhotonNetwork.Instantiate?