MasterServer.RequestHostList

Switch to Manual
public static void RequestHostList (string gameTypeName);

Description

从主服务器请求主机列表。

在列表到达时,可通过 MasterServer.PollHostList 进行使用。

using UnityEngine;
using System.Collections;

public class ExampleClass : 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(); } } }