Chat Refactor + Spawn Points Y Axis Fix

This commit is contained in:
pelpanagiotis
2026-01-16 08:19:14 +02:00
parent bc6989bf05
commit 71f1523dc7
63 changed files with 17493 additions and 1491 deletions

View File

@@ -0,0 +1,61 @@
using UnityEngine;
using UnityEngine.UI;
using Mirror;
using TMPro;
public class LoginUI : MonoBehaviour
{
[Header("UI Elements")]
[SerializeField] internal TMP_InputField usernameInput;
[SerializeField] internal Button clientButton;
[SerializeField] internal Text errorText;
public static LoginUI instance;
string originalNetworkAddress;
void Awake()
{
instance = this;
}
void Start()
{
if (string.IsNullOrWhiteSpace(NetworkManager.singleton.networkAddress))
NetworkManager.singleton.networkAddress = "localhost";
originalNetworkAddress = NetworkManager.singleton.networkAddress;
}
void Update()
{
if (string.IsNullOrWhiteSpace(NetworkManager.singleton.networkAddress))
NetworkManager.singleton.networkAddress = originalNetworkAddress;
}
public void ToggleButton(string username)
{
clientButton.interactable = !string.IsNullOrWhiteSpace(username);
}
public void OnClientButton()
{
var username = usernameInput.text.Trim();
if (string.IsNullOrWhiteSpace(username))
{
if (errorText != null) { errorText.text = "Enter a username"; errorText.gameObject.SetActive(true); }
return;
}
// set the name on the ChatAuthenticator (if present)
var auth = NetworkManager.singleton.GetComponent<ChatAuthenticator>();
if (auth != null)
auth.SetPlayerName(username);
else
Debug.LogWarning("LoginUI: ChatAuthenticator not found on NetworkManager.");
// start client
NetworkManager.singleton.StartClient();
}
}