Description
NetworkList doesn't synchronize initial values, when write permission is set to owner and values are added in OnNetworkSpawn.
Reproduce Steps
- Add the following script to your player owned prefab
- Host a game
- Connect an additional client to the host
- Check inspector on both host and client to see that the list values are missing on the Host, but available on the client.
Actual Outcome
Client set list values in OnNetworkSpawn are not synced to host.
Expected Outcome
List is synced with host.
Screenshots
public class Foo : NetworkBehaviour
{
public NetworkList<int> integers;
private void Awake()
{
integers = new NetworkList<int>(null, NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Owner);
}
public override void OnNetworkSpawn()
{
base.OnNetworkSpawn();
if (!IsOwner)
return;
for (var i = 0; i < 4; i++)
{
integers.Add(i);
}
}
}
Environment
- OS: Windows 11
- Unity Version: 6000.0.58f2
- Netcode Version: 2.8.0
- Netcode Commit: [e.g. https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/commit/ba418fa5b600ad9eb61fab0575f12fbecc2c6520]
- Netcode Topology: [e.g. Client-Server, Distributed Authority, etc.]
Additional Context
Updated from 2.4.4, where it worked as intended.
Description
NetworkList doesn't synchronize initial values, when write permission is set to owner and values are added in OnNetworkSpawn.
Reproduce Steps
Actual Outcome
Client set list values in OnNetworkSpawn are not synced to host.
Expected Outcome
List is synced with host.
Screenshots
Environment
Additional Context
Updated from 2.4.4, where it worked as intended.