public class Notification : MessageBase
{
public string content;
}
public class MessagesTest : MonoBehaviour
{
[SerializeField] private TMP_Text notificationsText = null;
private void Start()
{
if (!NetworkClient.active) { return; }
NetworkClient.RegisterHandler<Notification>(OnNotification);
}
private void OnNotification(NetworkConnection conn, Notification msg)
{
notificationsText.text += $"\n{msg.content}";
}
}
This had two errors, MessageBase became Deprecated, so needed to be changed to NetworkMessage.
Once it was changed to NetworkMessage, it had another error, "The type 'Notification' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'NetworkClient.RegisterHandler"
To fix that, I changed
public class Notification : MessageBase
{
public string content;
}
to
public struct Notification : MessageBase
{
public string content;
}