Okay so I’m trying to make a mobile LAN pong game. I’ve made a menu system using the new UI but there don’t seem to be any help videos that implements this feature yet. Ive been getting off okay so far, until I got to the part where the games currently up on the network come up. I know i have one running, but it doesn’t display it. Here is my code.
#pragma strict
var gameName : String = "Pong2D Multiplayer";
private var btnX : float;
private var btnY : float;
private var btnW : float;
private var btnH : float;
function Start(){
btnX = Screen.width * 0.05;
btnY = Screen.width * 0.05;
btnW = Screen.width * 0.1;
btnH = Screen.width * 0.1;
}
private var refreshing : boolean;
private var hostData : HostData[];
function startServer(){
Network.InitializeServer(32,25001, !Network.HavePublicAddress);
MasterServer.RegisterHost(gameName, "Server","This is another Player's server!");
}
function refreshHostList(){
MasterServer.RequestHostList(gameName);
refreshing = true;
}
function Update(){
if(refreshing){
if(MasterServer.PollHostList().Length > 0){
refreshing = false;
Debug.Log(MasterServer.PollHostList().Length);
hostData = MasterServer.PollHostList();
}
}
}
function OnServerInitialized(){
Debug.Log("Server Started!");
}
function OnMasterServerEvent(mse:MasterServerEvent){
if(mse == MasterServerEvent.RegistrationSucceeded){
Debug.Log("Registered Server!");
}
}
function onGUI(){
Debug.Log("Refreshing Hosts");
refreshHostList();
if(hostData){
for(var i:int = 0; i < hostData.length; i++){
if(GUI.Button(Rect(Screen.width - 100,0,100,50), "Pong Game")){
Network.Connect(hostData*);*
- }*
- }*
- }*
}