Skip to content

NetworkList<T> OnListChanged doesn't trigger on client #573

Description

@Rosme

Describe the bug
NetworkList OnListChanged event doesn't get triggered on Client. Host/Server works fine, but will not trigger on the Client. Client changes will not trigger the event on both Client and Host.

To Reproduce
See following code:
`public class ChatMessaging : NetworkBehaviour
{
public ChatBox chatBox;

static ChatMessaging s_Singleton;

public static ChatMessaging Singleton => s_Singleton != null ? s_Singleton : (s_Singleton = FindObjectOfType<ChatMessaging>());

NetworkList<string> m_chatMessages = new NetworkList<string>(new NetworkVariableSettings()
{
    ReadPermission = MLAPI.NetworkVariable.NetworkVariablePermission.Everyone,
    WritePermission = MLAPI.NetworkVariable.NetworkVariablePermission.Everyone,
    SendTickrate = 5
}, new List<string>());

void Start()
{
    m_chatMessages.OnListChanged += OnListChanged;
}

void OnListChanged(NetworkListEvent<string> changeEvent)
{
    Debug.Log(changeEvent.Value);
}

public void SendChatMessage(string message)
{
    m_chatMessages.Add(message);
}

}`

Expected behavior
NetworkList to be synced between host and client and for OnListChanged event to be invoked.

Screenshots
image

Environment (please complete the following information):

  • OS: macOS Catalina 10.15.7
  • Unity Version: 2020.2.7f1
  • MLAPI Version: release/0.1.0
  • MLAPI Commit: ddf9d9b

Additional context
Getting the following message at the same time:
[MLAPI] NETWORK_VARIABLE_DELTA message received for a non-existent object with networkObjectId: 3. This delta will be buffered and might be recovered.: UnityEngine.Debug:LogWarning (object)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions