using UnityEngine; using UnityEngine.UI; using System.Net; using System.Net.Sockets; public class MultiplayerMenuManager : MonoBehaviour { [Header("UI Panels")] public GameObject hostPopup; public GameObject joinPopup; [Header("Host Popup Elements")] public Text hostIPText; [Header("Join Popup Elements")] public InputField joinIPInput; // === Called when HOST button is clicked === public void OnClick_Host() { string localIP = GetLocalIPAddress(); hostIPText.text = "Your IP: " + localIP; hostPopup.SetActive(true); // Just show popup for now } public void OnClick_HostConfirm() { //NetworkManager.singleton.StartHost(); // Actually starts the host now } // === Called when JOIN button is clicked === public void OnClick_Join() { joinPopup.SetActive(true); } // === Called when JOIN > START is clicked === public void OnClick_JoinConfirm() { string ip = joinIPInput.text.Trim(); //if (!string.IsNullOrEmpty(ip)) //{ // NetworkManager.singleton.networkAddress = ip; // NetworkManager.singleton.StartClient(); //} } // === Close popups === public void OnClick_CloseAllPopups() { hostPopup.SetActive(false); joinPopup.SetActive(false); } // === Utility: Get local IP for LAN === private string GetLocalIPAddress() { string localIP = "Unavailable"; try { var host = Dns.GetHostEntry(Dns.GetHostName()); foreach (var ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { localIP = ip.ToString(); break; } } } catch { } return localIP; } }