-
Notifications
You must be signed in to change notification settings - Fork 463
Closed
Labels
type:bugBug ReportBug Report
Description
Describe the bug
I defined this component with a NetworkList field for a custom message
` public class Chat : NetworkBehaviour
{
public NetworkList chatMessagesNetworkList;
public override void OnNetworkSpawn()
{
if (IsServer)
{
chatMessagesNetworkList = new NetworkList<ChatNetMessage>();
}
chatMessagesNetworkList.OnListChanged += OnListChanged;
}
[ServerRpc]
public void SendChatMessageServerRpc(ulong clientId, string playerName = "", string message = "")
{
AddChatMessage(clientId, playerName, message);
}
public void AddChatMessage(ulong clientId, string playerName = "", string message = "")
{
var chatNetMessage = new ChatNetMessage(clientId, playerName, message);
chatMessagesNetworkList.Add(chatNetMessage);
}
...
`
The message
` public struct ChatNetMessage : INetworkSerializable, IEquatable
{
public ulong clientId;
public bool Equals(ChatNetMessage other)
{
return this.clientId == other.clientId && this.playerName == other.playerName && this.message == other.message;
}
public ChatNetMessage(ulong clientId, FixedString32Bytes playerName, FixedString32Bytes message)
{
this.clientId = clientId;
this.playerName = playerName;
this.message = message;
}
//public string playerName;
public FixedString32Bytes playerName;
//public string message;
public FixedString32Bytes message;
void INetworkSerializable.NetworkSerialize<T>(BufferSerializer<T> serializer)
{
//Debug.Log($"<color=lime>ChatNetMessage Serializing</color>");
serializer.SerializeValue(ref clientId);
serializer.SerializeValue<FixedString32Bytes>(ref playerName);
serializer.SerializeValue<FixedString32Bytes>(ref message);
}
}
`
To Reproduce
when I add a message (from the Host) it doesn't serialize the message and send it to the client
Actual outcome
Server does not serialize the message. No errors reported.
Expected outcome
Server should serialize the message and send it to the client should receive the message and OnListChanged event should fire.
.
Environment (please complete the following information):
- OS: MacOS 10.15.7
- Unity Version: 2020.3.15f2
- Netcode Version: #develop
- Netcode Commit: latest as of today
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type:bugBug ReportBug Report