MasterServer.RequestHostList 请求主机列表
static function RequestHostList (gameTypeName : string) : void
Description描述
Request a host list from the master server.
从主服务器请求一个主机列表。
The list is available through MasterServer.PollHostList when it has arrived.
当列表到达以后,它通过 MasterServer.PollHostList成为可用的。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void Awake() {
MasterServer.ClearHostList();
MasterServer.RequestHostList("LarusTest");
}
void Update() {
if (MasterServer.PollHostList().Length != 0) {
HostData[] hostData = MasterServer.PollHostList();
int i = 0;
while (i < hostData.Length) {
Debug.Log("Game name: " + hostData[i].gameName);
i++;
}
MasterServer.ClearHostList();
}
}
}
function Awake() {
// Make sure list is empty and request a new list
//确保列表是空的,请求一个新列表。
MasterServer.ClearHostList();
MasterServer.RequestHostList("LarusTest");
}
function Update() {
// If any hosts were received, display game name, the clear host list again
//如果任何主机被接收到,显示游戏名字,然后再次清空主机列表。
if (MasterServer.PollHostList().Length != 0) {
var hostData: HostData[] = MasterServer.PollHostList();
for (var i : int = 0; i < hostData.Length; i++)
Debug.Log("Game name: " + hostData[i].gameName);
MasterServer.ClearHostList();
}
}
最后修改:2011年1月4日 Tuesday 15:49