I am following a tutorial by dapper dino about using mirror chat system.(
) I followed to end but there is an error Assets\Chat\Scripts\ChatBehaviour.cs(14,26): error CS0115: ‘ChatBehaviour.OnStartAuthority()’: no suitable method found to override. I am using unity version 2021.2
using Mirror;
using System;
using TMPro;
using UnityEngine;
public class ChatBehaviour : MonoBehaviour
{
[SerializeField] private GameObject chatUI = null;
[SerializeField] private TMP_Text chatText = null;
[SerializeField] private TMP_InputField inputField = null;
private static event Action<string> OnMessage;
public override void OnStartAuthority()
{
chatUI.SetActive(true);
OnMessage += HandleNewMessage;
}
[ClientCallback]
private void OnDestroy()
{
if (!hasAuthority) { return; }
OnMessage -= HandleNewMessage;
}
private void HandleNewMessage(string message)
{
chatText.text += message;
}
[Client]
public void Send(string message)
{
if (!Input.GetKeyDown(KeyCode.Return)) { return; }
if (string.IsNullOrWhiteSpace(message)) { return; }
CmdSendMessage(message);
inputField.text = string.Empty;
}
[Command]
private void CmdSendMessage(string message)
{
RpcHandleMessage($"[{connectionToClient.connectionId}]: {message}");
}
[ClientRpc]
private void RpcHandleMessage(string message)
{
OnMessage?.Invoke($"\n{message}");
}
}