Skip to content

NetworkList<MyStruct> doesn't sync with clients. #1981

@TheCaveOfWonders

Description

@TheCaveOfWonders

Description

When using a NetworkList with a custom type (a struct that supports NetworkVariable), the list does not sync with clients.

Reproduce Steps

  1. Create a struct to be used with the NetworkList, let's call it MyStruct. Make sure it can be used as a NetworkVariable, so it needs to implement INetworkSerializeByMemcpy, IEquatable.
  2. Have a NetworkBehavior on a prefab that also contains the NetworkObject behavior.
  3. Use NetworkList in the NetworkBehavior, set it in the Awake call and add some elements to it.
  4. Instantiate the prefab on the server, and call Spawn on its NetworkObject so that it spawns on the clients as well.
  5. Notice how NetworkList does not sync on the clients.

Environment

  • OS: Win10
  • Unity Version: 2022.9
  • Netcode Version: 1.0.0-pre.9

Workaround

Once the GameObject has spawned for the clients, if on the server we do NetworkHide then wait a bit (50ms) then do NetworkShow, the NetworkList will now sync properly for the clients.

Metadata

Metadata

Assignees

Labels

priority:mediumThis issue has medium priority and may take some time to be resolvedstat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions