After updating my project from Unity 6.2 to 6.3 and NGO from 2.1.0 to 2.9.0 I noticed that in the ServerRpc attribute, the RequireOwnership property has been deprecated! After changing the attribute to use the recommended InvokePermission, I was getting errors in my game like these:
Only the owner can invoke a ServerRpc that requires ownership!
I found the reason for this is that the NetworkBehaviourILPP script still has two places where the InvokePermission is not looked at, and still uses requireOwnership, resulting in it defaulting to “true”!
-
InjectWriteAndCallBlock()
At line ~2182 it reads requireOwnership from the attribute, but doesn’t look at InvokePermission at all. -
GenerateStaticHandler()
At line ~2965 it reads requireOwnership from the attribute, but doesn’t look at InvokePermission at all.
After adding the following code snippets, the ServerRpcs are working as expected again!
case k_RpcAttribute_InvokePermission:
RpcInvokePermission invokePermission = (RpcInvokePermission)attrField.Argument.Value;
requireOwnership = invokePermission != RpcInvokePermission.Everyone;
break;
case k_RpcAttribute_InvokePermission:
RpcInvokePermission invokePermission = (RpcInvokePermission)attrField.Argument.Value;
requireOwnership = invokePermission != RpcInvokePermission.Everyone;
break;