Hi everyone. I have created this script which is attached to an empty object in my scene. It uses the master server to connect. When I press the connect button it prints “yay” but doesn’t connect. I am trying to connect to an executable (Mac) and the unity editor… Code:
var serverPort : String="25000";
var networkGameName : String;
private var hostNumber : int;
private var hostData: HostData[];
function Start (){
MasterServer.RequestHostList("GameType");
}
function Update (){
if(MasterServer.PollHostList().length>0){
hostData=MasterServer.PollHostList();
print(hostData[0].gameName);
}
}
function OnGUI (){
if(Network.peerType == NetworkPeerType.Disconnected){
networkGameName=GUI.TextField(Rect(5, 30, 150, 20), networkGameName, 20);
if(GUI.Button(Rect(5, 5, 150, 20),"NewServer")){
Network.InitializeServer(32, parseInt(serverPort), false);
MasterServer.RegisterHost("GameType", networkGameName, "Comment");
}
if(GUI.Button(Rect(200, 40, 30, 20),"<") && hostNumber>0){
hostNumber--;
}
if(GUI.Button(Rect(235, 40, 30, 20),">") && hostNumber<10){
hostNumber++;
}
if(hostData){
for(var element : HostData in hostData) {
var tmpIp : String = "";
tmpIp = element.ip[hostNumber] + " ";
Debug.Log(element.gameName + " ip: " + tmpIp + ":" + element.port);
Network.natFacilitatorIP = tmpIp;
Network.natFacilitatorPort = element.port;
}
if(GUI.Button(Rect(200,5,200,30), hostData[hostNumber].gameName)){
Network.Connect(tmpIp, hostData.port);
print("yay");
}
}else{
GUI.Button(Rect(200,5,200,30), "Can't Find Any Games!");
}
}
if(Network.peerType != NetworkPeerType.Disconnected){
if(GUI.Button(Rect(5, 5, 150, 20),"Disconnect")){
Network.Disconnect();
}
}
}
-------------------Can you see anything wrong?--------------------