Describe the bug
Hooks are invoked in the order the syncvars are defined in the file.
This does not apply for the Host.
On Host hooks are called in the order the corresponding syncvars are set.
On Client everything works as expected.
Technically this is not a problem because of "just set the variables as they are in the file and not random".
This is indeed correct but would not be consistent with the rest of Mirror.
[IMPORTANT] How can we reproduce the issue, step by step:
Open the Basic Example and add a new empty GameObject with the script below attached.
Press 'H' and watch the logs.
public class SyncVarTest : NetworkBehaviour
{
[SyncVar(hook = nameof(Hook1))]
int Y;
[SyncVar(hook = nameof(Hook2))]
int Z;
void Update()
{
if(isHost && Input.GetKeyDown(KeyCode.H))
{
CmdDoSomething();
}
}
[Command]
void CmdDoSomething()
{
Z = Random.Range(100, 500); // On Host this Hook fires first
Y = Random.Range(100, 500);
//Y = Random.Range(100, 500); // Hooks fire in the correct order
//Z = Random.Range(100, 500);
}
void Hook1(int oldValue, int newValue)
{
Debug.LogWarning($"IsHost: {isHost} | Hook1 fired");
}
void Hook2(int oldValue, int newValue)
{
Debug.LogWarning($"IsHost: {isHost} | Hook2 fired");
}
}
Expected behavior
Like the Docs says you would expect that on Host, Hook1 is called first and Hook2 follows.
Screenshots


Desktop:
- OS: Windows | Linux
- Build target: Standalone
- Unity version: 6000.0.29f1 | 2021.3.45f1
- Mirror branch: master[96.0.1] | master[96.10.0]
Additional context
Ignore the first Hook logs after starting as Host because this is another already known Issue.
Describe the bug
This does not apply for the Host.
On Host hooks are called in the order the corresponding syncvars are set.
On Client everything works as expected.
Technically this is not a problem because of "just set the variables as they are in the file and not random".
This is indeed correct but would not be consistent with the rest of Mirror.
[IMPORTANT] How can we reproduce the issue, step by step:
Open the Basic Example and add a new empty GameObject with the script below attached.
Press 'H' and watch the logs.
Expected behavior
Like the Docs says you would expect that on Host, Hook1 is called first and Hook2 follows.
Screenshots


Desktop:
Additional context
Ignore the first Hook logs after starting as Host because this is another already known Issue.