void Awake() { instance = this; t_searchTimeout = discoveryTimeout; // init netdiscovery netDiscovery = gameObject.AddComponent <DDNetDiscovery>(); netDiscovery.ddnet = this; netDiscovery.broadcastPort = portBroadcast; netDiscovery.showGUI = false; netDiscovery.useNetworkManager = false; // init netmanager netManager = gameObject.GetComponent <DDNetManager>(); netManager.networkPort = portGame; //gameObject.AddComponent<NetworkManagerHUD>(); }
// ---------------------------- CLIENT ------------------------------- public void OnReceivedBroadcast(string fromAddress, string data) { if (netManager.client != null) { return; } // stop broadcasting Destroy(netDiscovery); netDiscovery = null; isSearching = false; // parse address netManager.networkAddress = fromAddress.Substring(fromAddress.LastIndexOf(':') + 1); Debug.Log("connecting to: " + netManager.networkAddress + ":" + portGame.ToString()); netManager.StartClient(); RegisterClientHandlers(); }