Skip to content

NetworkList with Owner write permission doesn't sync values set in OnNetworkSpawn #3848

@ffejlersen

Description

@ffejlersen

Description

NetworkList doesn't synchronize initial values, when write permission is set to owner and values are added in OnNetworkSpawn.

Reproduce Steps

  1. Add the following script to your player owned prefab
  2. Host a game
  3. Connect an additional client to the host
  4. 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);
            }
        }
    }
Image

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.

Metadata

Metadata

Labels

priority:highThis issue has high priority and we are focusing to resolve itregressionThe issue is a regression (something that was working in previous version)stat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions