mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
docs: Updated SyncVar docs
This commit is contained in:
parent
e1d1d41ed6
commit
25edcf0d41
@ -5,6 +5,7 @@
|
||||
The hook attribute can be used to specify a function to be called when the SyncVar changes value on the client. This ensures that all clients receive the proper variables from other clients.
|
||||
- The Hook method must have a two parameters of the same type as the SyncVar property. One for the old value, one for the new value.
|
||||
- The Hook is always called after the value was set. You don't need to set it yourself.
|
||||
- The Hook only fires for changed values, and changing a value in the inspector will not trigger an update.
|
||||
|
||||
Below is a simple example of assigning a random color to each player when they're spawned on the server. All clients will see all players in the correct colors, even if they join later.
|
||||
|
||||
|
@ -8,7 +8,7 @@ The state of SyncVars is applied to game objects on clients before `OnStartClien
|
||||
|
||||
SyncVars can use any [type supported by Mirror](../DataTypes.md). You can have up to 64 SyncVars on a single NetworkBehaviour script, including SyncLists (see next section, below).
|
||||
|
||||
The server automatically sends SyncVar updates when the value of a SyncVar changes, so you do not need to track when they change or send information about the changes yourself.
|
||||
The server automatically sends SyncVar updates when the value of a SyncVar changes, so you do not need to track when they change or send information about the changes yourself. Changing a value in the inspector will not trigger an update.
|
||||
|
||||
> The [SyncVar hook](SyncVarHook.md) attribute can be used to specify a method to be called when the SyncVar changes value on the client.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user