Class ServerRpcAttribute
Marks a method as ServerRpc.
A ServerRpc marked method will be fired by a client but executed on the server.
Inherited Members
Namespace: Unity.Netcode
Assembly: Unity.Netcode.Runtime.dll
Syntax
[AttributeUsage(AttributeTargets.Method)]
public class ServerRpcAttribute : RpcAttribute
Constructors
ServerRpcAttribute()
Initializes a new instance of ServerRpcAttribute that targets the server
Declaration
public ServerRpcAttribute()
Fields
RequireOwnership
When true, only the owner of the NetworkObject can invoke this ServerRpc.
Declaration
[Obsolete("ServerRpc with RequireOwnership is deprecated. Use [Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)] or [Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Owner)] instead.)]")]
public bool RequireOwnership
Field Value
| Type | Description |
|---|---|
| bool |
Remarks
Deprecated in favor of using RpcAttribute with a Server target and an InvokePermission.
[ServerRpc(RequireOwnership = false)]
// is replaced with
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
// as InvokePermission has a default setting of RpcInvokePermission.Everyone, you can also use
[Rpc(SendTo.Server)]
[ServerRpc(RequireOwnership = true)]
// is replaced with
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Owner)]