How to disable RPC shortcuts?
Options
In the documentation about Shortcuts for RPC names it says on https://doc.photonengine.com/en-us/pun/v2/gameplay/rpcsandraiseevent
"Due to this shortcut, different builds of games maybe don't use the same IDs for RPCs. If this is a problem, you can disable the shortcut."
But how do I do that? Is it enough to just clear the list of RPCs in the PhotonServerSettings?
"Due to this shortcut, different builds of games maybe don't use the same IDs for RPCs. If this is a problem, you can disable the shortcut."
But how do I do that? Is it enough to just clear the list of RPCs in the PhotonServerSettings?
0
Answers
-
That list seems to get recreated on each compilation though.
You'd either have to clear the list each time you change a script, which is obviously not practical.
Or you could clear the list each time before you do a build, but that also seems hacky. You could forget, and you'd develop with different settings than the ones you're releasing with.
The actual problem I'm trying to solve is, that I want to ensure backwards compatibility between versions. Ideally I'd want to be able to use the [PunRPC] attribute with an optional parameter like so [PunRPC(1)]. That would allow me to specify the ID / RPC shortcut myself instead of relying on the list in the ServerSettings always being the same.
I can see why it was implemented with auto-assigning IDs via the attribute. That way Photon uses efficient IDs instead of strings by default without requiring extra effort for developers that are new to networking. But I think it'd be useful to have the option to control the IDs for each RPC manually.0 -
That list seems to get recreated on each compilation though.I will discuss with the team if this is expected/intended behaviour and for the best way to do not use RPC shortucts.
You'd either have to clear the list each time you change a script, which is obviously not practical.
Or you could clear the list each time before you do a build, but that also seems hacky. You could forget, and you'd develop with different settings than the ones you're releasing with.But I think it'd be useful to have the option to control the IDs for each RPC manually.You can assign the RPC shortcuts manually from the Editor
1 -
You can assign the RPC shortcuts manually from the Editor.Can you elaborate on that? Where/how can I edit the shortcuts? I don't seem to be able to edit the fields in the PhotonServerSettings.0
-
Hi,
Actually, you can't do that as is.
you can alter the rpc list itself via PhotonNetwork.PhotonServerSettings.RpcList
but the actual shortcuts are generated by PhotonNetwork during initialization, and it's a private readonly property, it's PhotonNetworkPart.rpcShortcuts
so if you want to control the shortcuts, then you need to turn this to public and writeable, and alter that after PhotonNetwork As Initialize, I would just force it after you connected, which ensures PhotonNetwork was instantiated.
We do not recommend altering the code base of course, because you loose your work during PUN updates.
Of course, depending on what RPC you need to call, maybe raising events directly could be an option for you. Else, the best way is to control the Server settings RPC list to be as you want it and let PUN do the shortcuts.
Bye,
Jean
0