startPageNumber | 将在返回结果中列出的当前页面。 |
resultPageSize | 所请求页面的大小。这决定了传入回调的匹配列表中包含的最大匹配数量。 |
matchNameFilter | 文本字符串名称筛选器。这是针对当前处于活动状态的匹配名称的部分通配符搜索,并且可视为等同于 *<matchNameFilter>* 的匹配,其中包含此处提供的完整字符串的任何结果都将出现在结果集中。 |
filterOutPrivateMatchesFromResults | 指示响应是否应包含私有匹配(指有密码保护的匹配)的布尔值。 |
eloScoreTarget | 将分组的匹配列表结果的 Elo 得分目标。如果使用了该参数,则应将其设置为列出匹配的客户端的 Elo 等级,从而结果将与玩家的技能等级更匹配。如未使用,则可以将其与函数中的所有其他 Elo 引用(如 NetworkMatch.CreateMatch 或 NetworkMatch.JoinMatch)一起设置为 0。 |
requestDomain | 此请求的请求域。只有同一域中的请求可以相互连接。例如,如果使用域 1 创建 NetworkMatch.CreateMatch,则只有也指定了域 1 的 ListMatches 才能找到该匹配。使用此值来接收不同(可能不兼容)的客户端版本。 |
callback | 在 MatchMaker 上完成此调用后调用的回调。 |
Coroutine 这是一个异步函数,将在未来某个时刻(即协程结束与服务后端的通信时)完成。
用于列出 MatchMaker 中正在进行的匹配的函数。
NetworkMatch.ListMatches 函数返回当前活动匹配的基于页面的结果,这些匹配与提供给该函数的参数一致。
您最初应该使用从 0 开始的页码以及合理的页面大小(例如,10)来调用此函数。页面过大会延长下载与这些匹配相关的信息所需的时间。回调将使用包含以 resultPageSize 为最多匹配数的数据进行调用(例如,如果当前 startPageNumber 为 3,resultPageSize 为 5,则传入回调的数据将会是结果列表中对应于结果 15-20 的匹配)。之后您可以重复调用此函数,增加 startPageNumber 并保持固定的 resultPageSize 和 matchNameFilter,以使结果保持半稳定状态(您可以在调用此函数时创建或销毁匹配,这将反映在结果中。)
using UnityEngine; using UnityEngine.Networking; using UnityEngine.Networking.Match; using System.Collections.Generic;
public class ExampleScript : MonoBehaviour { void Start() { NetworkManager.singleton.StartMatchMaker(); NetworkManager.singleton.matchMaker.ListMatches(0, 10, "", true, 0, 0, OnMatchList); }
public void OnMatchList(bool success, string extendedInfo, List<MatchInfoSnapshot> matches) { // ... } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.