Chat System Setup

This commit is contained in:
pelpanagiotis
2025-12-23 21:43:28 +02:00
parent 329b7d3183
commit 6262ec6b61
3474 changed files with 425014 additions and 28055 deletions

View File

@@ -0,0 +1,28 @@
using Mirror;
using System;
using UnityEngine;
public class SpawnScript : NetworkBehaviour
{
public GameObject chatPrefab;
public static event Action<string> OnMessage;
public override void OnStartServer()
{
GameObject obj = Instantiate(chatPrefab);
NetworkServer.Spawn(obj);
}
[Command]
public void CmdSendMessage(string message)
{
RpcHandleMessage($"[{connectionToClient.connectionId}]: {message}");
}
[ClientRpc]
private void RpcHandleMessage(string message)
{
OnMessage?.Invoke($"\n{message}");
}
}