public Coroutine CreateMatch (string matchName, uint matchSize, bool matchAdvertise, string matchPassword, string publicClientAddress, string privateClientAddress, int eloScoreForMatch, int requestDomain, DataResponseDelegate<MatchInfo> callback);

Parámetros

matchNameThe text string describing the name for this match.
matchSizeWhen creating a match, the matchmaker will use either this value, or the maximum size you have configured online at https://multiplayer.unity3d.com, whichever is lower. This way you can specify different match sizes for a particular game, but still maintain an overall size limit in the online control panel.
matchAdvertiseA bool indicating if this match should be available in NetworkMatch.ListMatches results.
matchPasswordA text string indicating if this match is password protected. If it is, all clients trying to join this match must supply the correct match password.
publicClientAddressThe optional public client address. This value is stored on the matchmaker and given to clients listing matches. It is intended to be a network address for connecting to this client directly over the internet. This value will only be present if a publicly available address is known, and direct connection is supported by the matchmaker.
privateClientAddressThe optional private client address. This value is stored on the matchmaker and given to clients listing matches. It is intended to be a network address for connecting to this client directly on a local area network. This value will only be present if direct connection is supported by the matchmaker. This may be an empty string and it will not affect the ability to interface with matchmaker or use relay server.
eloScoreForMatchThe Elo score for the client hosting the match being created. If this number is set on all clients to indicate relative skill level, this number is used to return matches ordered by those that are most suitable for play given a listing player's skill level. This may be 0 on all clients, which would disable any Elo calculations in the MatchMaker.
requestDomainThe request domain for this request. Only requests in the same domain can interface with each other. For example if a NetworkMatch.CreateMatch is made with domain 1, only ListMatches that also specify domain 1 will find that match. Use this value to silo different (possibly incompatible) client versions.
callbackThe callback to be called when this function completes. This will be called regardless of whether the function succeeds or fails.

Valor de retorno

Coroutine This function is asynchronous and will complete at some point in the future, when the coroutine has finished communicating with the service backend.

Descripción

Use this function to create a new match. The client which calls this function becomes the host of the match.

When creating a match you should call this function and wait for the callback to be invoked before proceeding. The callback will indicate if the call was successful as well as extended information if it failed. After receiving the response callback you then should call StartHost() with the passed in MatchInfo.

using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.Match;

public class ExampleScript : MonoBehaviour { void Start() { NetworkManager.singleton.StartMatchMaker(); NetworkManager.singleton.matchMaker.CreateMatch("roomName", 4, true, "", "", "", 0, 0, OnMatchCreate); }

public void OnMatchCreate(bool success, string extendedInfo, MatchInfo matchInfo) { // ... } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961