docs: adding information about SyncVar Hook call order

This commit is contained in:
James Frowen 2021-01-22 01:17:45 +00:00 committed by GitHub
parent bce042907c
commit f24097d370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,3 +43,31 @@ public class PlayerController : NetworkBehaviour
}
}
```
## Hook call order
Hooks are invoked in the order the syncvars are defined in the file.
```cs
public class MyBehaviour : NetworkBehaviour
{
[SyncVar]
int X;
[SyncVar(hook = nameof(Hook1))]
int Y;
[SyncVar(hook = nameof(Hook2))]
int Z;
}
```
if X, Y, and Z are all set on the server at the same time then the call order will be:
1) X value is set
2) Y value is set
3) Hook1 is called
4) Z value is set
5) Hook2 is called