I have written the following code for automatically connecting to a LAN game. A pair of buttons call startLanHost and startClient. When running two builds of the game OnReceivedBroadcast is never called by a client. Is my code not written correctly?
public class NetworkConnector : NetworkDiscovery {
public NetworkManager networkManger;
public bool gameFound;
public bool lookingForGame;
public string networkAddress;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
if (lookingForGame && gameFound)
{
networkManger.StartClient();
}
}
public void startLanHost()
{
Initialize();
networkManger.StartHost();
StartAsServer();
}
public void startClient()
{
Initialize();
StartAsClient();
lookingForGame = true;
}
public override void OnReceivedBroadcast(string fromAddress, string data)
{
Debug.Log("Revcieved broadcast");
networkManger.networkAddress = fromAddress;
gameFound = true;
}
}