The code below is how we can host or join a game using unity networking system. As you see in the code below there is two input fields that normally take "localhost" and "7777".
public class CustomNetworkManager : NetworkManager {
[SerializeField] InputField InputField_IP;
[SerializeField] InputField InputField_Port;
public void HostGame()
{
singleton.networkPort = InputField_Port.text;
singleton.StartHost();
}
public void JoinGame()
{
singleton.networkPort = InputField_Port.text;
singleton.networkAddress = InputField_IP.text;
singleton.StartClient();
}
}
But I want to create a game that a player can host a game then his IP an port will be shown (for example) in a UI text and he could send that IP and port to other players and they could join the game. I am still new to networking and can someone tell me please is that could be done and is there a way to join a host that is connected to internet but you are not on the same network? Note: I am talking about android devices.