Ok, so I managed to build a simple network interface that tells whenever you’re client or a host, but it only works in localhost (web player and standalone). I tried building a android version with my PC’s global IP, but it doesn’t work. Here’s my code:
`
public string connectionIP = "127.0.0.1";
public int connectionPort = 25001;
public Text displayText;
void Start()
{
displayText.text = "";
}
void OnGUI() {
if (Network.peerType == NetworkPeerType.Disconnected)
{
GUI.Label (new Rect (10, 10, 200, 20), "Status: Disconnected");
}
if(GUI.Button(new Rect(10,70,120,30), "Client Connect"))
{
Network.Connect (connectionIP, connectionPort);
}
if (GUI.Button (new Rect (10, 50, 120, 20), "Initialize Server")) {
Network.InitializeServer (32, connectionPort, false);
} else if (Network.peerType == NetworkPeerType.Client)
{
GUI.Label (new Rect (10, 10, 200, 20), "Connected as client");
}
if(GUI.Button(new Rect(10,30,120,20),"Disconnect"))
{
Network.Disconnect(200);
}
}
void Update()
{
if (Network.isClient)
{
displayText.text = "you are a client";
}
if (Network.isServer)
{
displayText.text = "you are a host";
}
}
}
`