- PortalTestDestination practice range: Valorant-style hitscan rifle (recoil, spray/bloom, reload, controller support), debug HUD, practice-dummy targets with head/body hitboxes, hit/death/respawn animations, procedural SFX/FX - AK47 model (Quaternius, CC0) held via Animator IK, with fire/reload/equip anims - Intro cinematic (camera shots, title card, target beam-in, GO hand-off) - Scene dressing editor pass: CC0 textures, props, warehouse roof, lighting and post-processing; custom stylized skybox shader - CharacterMovement: camera recoil, shoulder offset, cinematic control lock - Unity CLI pipeline package; plus in-progress chat/Rive/player changes Asset credits: Assets/Models/Props/PROPS_CREDITS.txt (3 CC-BY 3.0 props), Assets/Textures/Range/TEXTURES_LICENSE.txt, Assets/Resources/*/..._LICENSE.txt Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.0 KiB
C#
69 lines
2.0 KiB
C#
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();
|
|
|
|
Debug.Log($"[LoginUI] Client button pressed. Username length: {username.Length}");
|
|
|
|
if (string.IsNullOrWhiteSpace(username))
|
|
{
|
|
Debug.LogWarning("[LoginUI] Client start blocked because the username is empty.");
|
|
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)
|
|
{
|
|
Debug.Log("[LoginUI] Assigning username to ChatAuthenticator.");
|
|
auth.SetPlayerName(username);
|
|
}
|
|
else
|
|
Debug.LogWarning("LoginUI: ChatAuthenticator not found on NetworkManager.");
|
|
|
|
// start client
|
|
Debug.Log($"[LoginUI] Starting client. Network address: '{NetworkManager.singleton.networkAddress}'");
|
|
NetworkManager.singleton.StartClient();
|
|
}
|
|
}
|