PunRPC Help

TobiasTobias admin
It seems there are various issues with the PunRPC attribute. Some are import problems of Unity, it seems, some are maybe related to IL2CPP or other issues.
This post is to give you some background why PunRPC is there, what you could try to work around issues, etc..

Why PunRPC

The RPC attribute everyone is used to became obsolete in Unity 5.1. Unity's old networking API will be removed from Unity soon, it seems.
Being obsolete, code with [RPC] will cause compile warnings and those are annoying.
We wrote a new attribute PunRPC and a script to search and replace the old attribute in your source. It should pop up when you are still using RPC somewhere.

PunRPC Is Missing

Check if the file RPC.cs got imported and if it contains the PunRPC class. If it's missing or has old content: Import PUN again. Or import PUN into a new, empty project and copy the file from there to your project.
If Unity could not compile all code, PunRPC might be missing because it couldn't compile the whole project.
Make sure you don't have other compile issues.

Also make sure your code actually uses [PunRPC] or @PunRPC to mark methods.

RPC List Refresh

Changing the attribute might re-calculate the RPC list in the PhotonServerSettings file. Select it in your project, unfold the RPC List and at the bottom press "Clear RPCs" and then "Refresh RPCs".
Now you definitely have a fresh list of RPCs in your game. Make sure only clients with the same list are talking to each other.
You can set a new game version to separate your new build from others (use PhotonNetwork.gameVersion or set it in PhotonNetwork.ConnectUsingSettings(string gameVersion).


If this doesn't help, please post your Unity version number and if you use PUN Free or Plus and which platform export is affected.
Sign In or Register to comment.