Connection Establishment using IP Mirror
parent
792f15f474
commit
119e95b787
@ -0,0 +1,16 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class GameUIManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static GameUIManager Instance;
|
||||||
|
|
||||||
|
[Header("NOS UI")]
|
||||||
|
public Image boostBarFill;
|
||||||
|
public Button boostButton;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
Instance = this;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7193227ad86d45a40864c925afb612e8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,74 @@
|
|||||||
|
using Mirror;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5c7910c0c5d39bb47b6ce491363c38be
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6cb797167da9e7f44925842f39f21c49
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b7ef0b21caef7df4fbaf32ff73da212f
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5906ecf9ac800ca43864c639d1817021
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue