<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mindattic.com/wiki/docs/index.php?action=history&amp;feed=atom&amp;title=Unity.Multiplayer%2Farticles%2Fattributes</id>
	<title>Unity.Multiplayer/articles/attributes - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mindattic.com/wiki/docs/index.php?action=history&amp;feed=atom&amp;title=Unity.Multiplayer%2Farticles%2Fattributes"/>
	<link rel="alternate" type="text/html" href="https://mindattic.com/wiki/docs/index.php?title=Unity.Multiplayer/articles/attributes&amp;action=history"/>
	<updated>2026-12-05T08:29:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.3</generator>
	<entry>
		<id>https://mindattic.com/wiki/docs/index.php?title=Unity.Multiplayer/articles/attributes&amp;diff=905&amp;oldid=prev</id>
		<title>Docs Sync: md2wiki: sync from MindAttic.Docs</title>
		<link rel="alternate" type="text/html" href="https://mindattic.com/wiki/docs/index.php?title=Unity.Multiplayer/articles/attributes&amp;diff=905&amp;oldid=prev"/>
		<updated>2026-11-29T20:36:28Z</updated>

		<summary type="html">&lt;p&gt;md2wiki: sync from MindAttic.Docs&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Attributes reference =&lt;br /&gt;
&lt;br /&gt;
Every networked class is a &amp;lt;code&amp;gt;partial class&amp;lt;/code&amp;gt; deriving from &amp;lt;code&amp;gt;NetEntity&amp;lt;/code&amp;gt; (the base type lives in the adapter assembly, &amp;lt;code&amp;gt;Unity.Multiplayer&amp;lt;/code&amp;gt;; see [[Unity.Multiplayer/articles/getting-started|Getting started]]). Five attributes, all in the &amp;lt;code&amp;gt;Unity.Multiplayer.Core&amp;lt;/code&amp;gt; API reference, describe its whole networked surface; the package&amp;#039;s source generator writes the RPC plumbing (the sending body and the NGO stub) for every attributed member when the script compiles, and a Roslyn analyzer rejects shapes that can&amp;#039;t work before the build even finishes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;public partial class CursorAvatar : NetEntity&lt;br /&gt;
{&lt;br /&gt;
    [ToServer(Delivery = Delivery.Unreliable, RateLimit = 30)]&lt;br /&gt;
    public partial void Move(Vector2 worldPos);                 // call site: Move(p)&lt;br /&gt;
&lt;br /&gt;
    [ToClients]&lt;br /&gt;
    public partial void Bumped();&lt;br /&gt;
&lt;br /&gt;
    [ToOwner]&lt;br /&gt;
    public partial void Denied(string reason);&lt;br /&gt;
&lt;br /&gt;
    [ToClient]&lt;br /&gt;
    public partial void Whisper(ulong target, string text);&lt;br /&gt;
&lt;br /&gt;
    [Synced(OnChanged = nameof(OnMassChanged))]&lt;br /&gt;
    private float _mass = 1f;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [ToServer] — client calls the server ==&lt;br /&gt;
&lt;br /&gt;
Call it anywhere on the owning client; the server runs &amp;lt;code&amp;gt;On&amp;amp;lt;Name&amp;gt;(&amp;amp;lt;same parameters&amp;gt;[, NetSender sender])&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Property&lt;br /&gt;
! Default&lt;br /&gt;
! What it does&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Delivery&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;Reliable&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;Reliable&amp;lt;/code&amp;gt; arrives in order with the object&amp;#039;s other reliable RPCs; &amp;lt;code&amp;gt;Unreliable&amp;lt;/code&amp;gt; may drop or arrive out of order — for high-rate state like a cursor position, where the next call supersedes this one.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;RateLimit&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; (no limit)&lt;br /&gt;
| Most calls per second the server accepts from one sender (a token bucket refilled at this rate). A call over the limit is dropped and reported through [[Unity.Multiplayer/articles/topologies|&amp;lt;code&amp;gt;NetSession.RpcRejected&amp;lt;/code&amp;gt;]], never handled.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Burst&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; (= &amp;lt;code&amp;gt;RateLimit&amp;lt;/code&amp;gt;, one second&amp;#039;s worth)&lt;br /&gt;
| How many calls a sender may make back to back before &amp;lt;code&amp;gt;RateLimit&amp;lt;/code&amp;gt; applies — the bucket&amp;#039;s size.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;RequireOwnership&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;: only the entity&amp;#039;s owner may call it; anyone else&amp;#039;s call is dropped. &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;: any connected client may call it (a shared button, a vote).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;[ToServer(RateLimit = 20)]&lt;br /&gt;
public partial void SetDirection(Vector2 direction);&lt;br /&gt;
&lt;br /&gt;
private void OnSetDirection(Vector2 direction, NetSender sender)&lt;br /&gt;
{&lt;br /&gt;
    _direction = Vector2.ClampMagnitude(direction, 1f);&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The handler may leave out the trailing &amp;lt;code&amp;gt;NetSender sender&amp;lt;/code&amp;gt; parameter when it doesn&amp;#039;t need the caller&amp;#039;s identity. When it&amp;#039;s kept, &amp;lt;code&amp;gt;sender&amp;lt;/code&amp;gt; converts implicitly to its &amp;lt;code&amp;gt;ulong&amp;lt;/code&amp;gt; client id, so a handler can answer whoever called it through a &amp;lt;code&amp;gt;[ToClient]&amp;lt;/code&amp;gt; method: &amp;lt;code&amp;gt;Denied(sender, &amp;quot;Not your turn&amp;quot;)&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;NetSender&amp;lt;/code&amp;gt; also carries &amp;lt;code&amp;gt;SeatIndex&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;DisplayName&amp;lt;/code&amp;gt; (see [[Unity.Multiplayer/articles/reconnect-seats|Reconnect and seats]]) and &amp;lt;code&amp;gt;IsServer&amp;lt;/code&amp;gt; (true for the host&amp;#039;s own player calling itself). Before the handler runs, the server checks ownership and the rate; a call that fails either is never handled.&lt;br /&gt;
&lt;br /&gt;
== [ToClients] — server calls every client ==&lt;br /&gt;
&lt;br /&gt;
Only the server may call it. Every client, the host&amp;#039;s own player included, runs &amp;lt;code&amp;gt;On&amp;amp;lt;Name&amp;gt;(&amp;amp;lt;same parameters&amp;gt;)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Property&lt;br /&gt;
! Default&lt;br /&gt;
! What it does&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Delivery&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;Reliable&amp;lt;/code&amp;gt;&lt;br /&gt;
| Same meaning as &amp;lt;code&amp;gt;[ToServer]&amp;lt;/code&amp;gt;&amp;#039;s.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;[ToClients]&lt;br /&gt;
public partial void Bumped();&lt;br /&gt;
&lt;br /&gt;
private void OnBumped() { _flashUntil = Time.time + 0.2f; }&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [ToOwner] — server calls the entity&amp;#039;s owner ==&lt;br /&gt;
&lt;br /&gt;
Only the server may call it; the owning client runs &amp;lt;code&amp;gt;On&amp;amp;lt;Name&amp;gt;(&amp;amp;lt;same parameters&amp;gt;)&amp;lt;/code&amp;gt;. Same &amp;lt;code&amp;gt;Delivery&amp;lt;/code&amp;gt; option as &amp;lt;code&amp;gt;[ToClients]&amp;lt;/code&amp;gt;. Use it for feedback that only matters to one player (a rejected action, a private prompt).&lt;br /&gt;
&lt;br /&gt;
== [ToClient] — server calls one specific client ==&lt;br /&gt;
&lt;br /&gt;
Only the server may call it. Its &amp;lt;strong&amp;gt;first parameter must be a &amp;lt;code&amp;gt;ulong&amp;lt;/code&amp;gt; target client id&amp;lt;/strong&amp;gt; — the generator rejects any other shape (MAMP010); that client runs &amp;lt;code&amp;gt;On&amp;amp;lt;Name&amp;gt;(&amp;amp;lt;the remaining parameters&amp;gt;)&amp;lt;/code&amp;gt;. Same &amp;lt;code&amp;gt;Delivery&amp;lt;/code&amp;gt; option. Pass a &amp;lt;code&amp;gt;NetSender&amp;lt;/code&amp;gt; directly as the target; it converts implicitly to the &amp;lt;code&amp;gt;ulong&amp;lt;/code&amp;gt; the attribute requires.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;[ToClient]&lt;br /&gt;
public partial void Whisper(ulong target, string text);&lt;br /&gt;
&lt;br /&gt;
// called as: Whisper(sender, &amp;quot;only you see this&amp;quot;)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [Synced] — server-owned replicated state ==&lt;br /&gt;
&lt;br /&gt;
Marks a &amp;lt;strong&amp;gt;field&amp;lt;/strong&amp;gt; (never a method) as replicated state. &amp;lt;code&amp;gt;[Synced] float _mass;&amp;lt;/code&amp;gt; becomes a &amp;lt;code&amp;gt;Mass&amp;lt;/code&amp;gt; property backed by a network variable: the server writes it, every client reads the same value, and a late joiner gets the current value as soon as it spawns.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Property&lt;br /&gt;
! Default&lt;br /&gt;
! What it does&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;OnChanged&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;nameof(Handler)&amp;lt;/code&amp;gt; of a &amp;lt;code&amp;gt;void Handler(T previous, T current)&amp;lt;/code&amp;gt; method on the same class, called on every peer (server included) whenever the value changes.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;[Synced(OnChanged = nameof(OnMassChanged))]&lt;br /&gt;
private float _mass = 1f;&lt;br /&gt;
&lt;br /&gt;
private void OnMassChanged(float previous, float current) { /* react to the change */ }&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rules the generator and analyzer enforce:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Always use the generated property (&amp;lt;code&amp;gt;Mass&amp;lt;/code&amp;gt;), never the field (&amp;lt;code&amp;gt;_mass&amp;lt;/code&amp;gt;).&amp;lt;/strong&amp;gt; Reading the field directly is a warning (MAMP007); writing it directly is an error (MAMP006) — the compiler catches a client trying to assert authoritative state before it ever runs (BIBLE UM-LAW-1).&lt;br /&gt;
* A constant field initializer becomes the network variable&amp;#039;s first value; a non-constant initializer is rejected (MAMP013).&lt;br /&gt;
* The field must not be &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;readonly&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;const&amp;lt;/code&amp;gt;, and its generated property name must not collide with an existing member (MAMP012).&lt;br /&gt;
&lt;br /&gt;
To find an object itself by a name the game chooses (a level&amp;#039;s block id, &amp;lt;code&amp;gt;&amp;quot;door:A&amp;quot;&amp;lt;/code&amp;gt;), not by spawn order, give its prefab a &amp;lt;code&amp;gt;NetKey&amp;lt;/code&amp;gt; and spawn it with &amp;lt;code&amp;gt;session.Objects.Spawn(prefab, key)&amp;lt;/code&amp;gt;; every peer then looks it up with &amp;lt;code&amp;gt;session.Objects.TryGet(key, out T)&amp;lt;/code&amp;gt;. See [[Unity.Multiplayer/articles/objects|Networked objects by key]].&lt;br /&gt;
&lt;br /&gt;
== How a call is handled, and what the generator writes ==&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;code&amp;gt;[ToServer]&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;[ToClients]&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;[ToOwner]&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;[ToClient]&amp;lt;/code&amp;gt;, the method you declare is the &amp;lt;strong&amp;gt;send side&amp;lt;/strong&amp;gt; — you call it like any method and the generator-written body actually sends it (&amp;lt;code&amp;gt;MoveServerRpc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;...ClientsRpc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;...OwnerRpc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;...ClientRpc&amp;lt;/code&amp;gt; underneath, each carrying the attribute&amp;#039;s &amp;lt;code&amp;gt;Delivery&amp;lt;/code&amp;gt;). A host calling a &amp;lt;code&amp;gt;[ToServer]&amp;lt;/code&amp;gt; method on itself runs the handler locally with the host as the sender. Every RPC and synced signature in an assembly is hashed into one &amp;lt;code&amp;gt;&amp;amp;#91;assembly: NetProtocolAttribute]&amp;lt;/code&amp;gt; (protocol hash); a connecting client whose assembly doesn&amp;#039;t match is rejected at approval before any gameplay code runs — see [[Unity.Multiplayer/articles/reconnect-seats#Connection approval|Reconnect and seats]].&lt;br /&gt;
&lt;br /&gt;
== Generator diagnostics ==&lt;br /&gt;
&lt;br /&gt;
The analyzer reports these at compile time (&amp;lt;code&amp;gt;MAMP&amp;lt;/code&amp;gt; = MindAttic MultiPlayer), so a mistake here is a build error or warning, not a runtime surprise:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! ID&lt;br /&gt;
! Severity&lt;br /&gt;
! Means&lt;br /&gt;
|-&lt;br /&gt;
| MAMP001&lt;br /&gt;
| Error&lt;br /&gt;
| An RPC method (or its type) isn&amp;#039;t &amp;lt;code&amp;gt;partial&amp;lt;/code&amp;gt;, or already has a body.&lt;br /&gt;
|-&lt;br /&gt;
| MAMP002&lt;br /&gt;
| Error&lt;br /&gt;
| An RPC method has no matching &amp;lt;code&amp;gt;On&amp;amp;lt;Name&amp;gt;&amp;lt;/code&amp;gt; handler.&lt;br /&gt;
|-&lt;br /&gt;
| MAMP003&lt;br /&gt;
| Error&lt;br /&gt;
| An RPC parameter&amp;#039;s type can&amp;#039;t be sent.&lt;br /&gt;
|-&lt;br /&gt;
| MAMP004&lt;br /&gt;
| Error&lt;br /&gt;
| A &amp;lt;code&amp;gt;[Synced]&amp;lt;/code&amp;gt; field&amp;#039;s type can&amp;#039;t be a network variable.&lt;br /&gt;
|-&lt;br /&gt;
| MAMP005&lt;br /&gt;
| Error&lt;br /&gt;
| A &amp;lt;code&amp;gt;NetEntity&amp;lt;/code&amp;gt; subclass is generic (NGO can&amp;#039;t give it stable RPC ids).&lt;br /&gt;
|-&lt;br /&gt;
| MAMP006&lt;br /&gt;
| Error&lt;br /&gt;
| Code writes a &amp;lt;code&amp;gt;[Synced]&amp;lt;/code&amp;gt; field directly instead of its generated property.&lt;br /&gt;
|-&lt;br /&gt;
| MAMP007&lt;br /&gt;
| Warning&lt;br /&gt;
| Code reads a &amp;lt;code&amp;gt;[Synced]&amp;lt;/code&amp;gt; field directly instead of its generated property.&lt;br /&gt;
|-&lt;br /&gt;
| MAMP008&lt;br /&gt;
| Error&lt;br /&gt;
| An RPC or &amp;lt;code&amp;gt;[Synced]&amp;lt;/code&amp;gt; attribute sits on a type that isn&amp;#039;t a &amp;lt;code&amp;gt;NetEntity&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| MAMP009&lt;br /&gt;
| Error&lt;br /&gt;
| An RPC method&amp;#039;s shape isn&amp;#039;t allowed (non-&amp;lt;code&amp;gt;void&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;, generic, &amp;lt;code&amp;gt;ref&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;out&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt;, more than one direction attribute).&lt;br /&gt;
|-&lt;br /&gt;
| MAMP010&lt;br /&gt;
| Error&lt;br /&gt;
| A &amp;lt;code&amp;gt;[ToClient]&amp;lt;/code&amp;gt; method&amp;#039;s first parameter isn&amp;#039;t the &amp;lt;code&amp;gt;ulong&amp;lt;/code&amp;gt; target client id.&lt;br /&gt;
|-&lt;br /&gt;
| MAMP011&lt;br /&gt;
| Error&lt;br /&gt;
| &amp;lt;code&amp;gt;[Synced(OnChanged = ...)]&amp;lt;/code&amp;gt; names no matching &amp;lt;code&amp;gt;void Handler(T previous, T current)&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| MAMP012&lt;br /&gt;
| Error&lt;br /&gt;
| A &amp;lt;code&amp;gt;[Synced]&amp;lt;/code&amp;gt; field is &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;readonly&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;const&amp;lt;/code&amp;gt;, or its property name is already taken.&lt;br /&gt;
|-&lt;br /&gt;
| MAMP013&lt;br /&gt;
| Error&lt;br /&gt;
| A &amp;lt;code&amp;gt;[Synced]&amp;lt;/code&amp;gt; field&amp;#039;s initializer isn&amp;#039;t a compile-time constant.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See [[Unity.Multiplayer/articles/troubleshooting|Troubleshooting]] for what to do when one of these fires, and [[Unity.Multiplayer/articles/testing#Generators.Tests|Testing]] for how &amp;lt;code&amp;gt;Generators.Tests&amp;lt;/code&amp;gt; pins one test per diagnostic.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;md2wiki-crumb&amp;quot;&amp;gt;Part of [[Unity.Multiplayer]].&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;md2wiki-source&amp;quot;&amp;gt;From [https://github.com/mindattic/Unity.Multiplayer/blob/main/docs/articles/attributes.md Unity.Multiplayer/docs/articles/attributes.md] via MindAttic.Docs; synced automatically, so edit the repo, not this page.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Unity.Multiplayer]]&lt;/div&gt;</summary>
		<author><name>Docs Sync</name></author>
	</entry>
</feed>