Version: 2018.4
LanguageEnglish
  • C#
Method group is Obsolete

NetworkMatch.CreateMatch

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete The matchmaker and relay feature will be removed in the future, minimal support will continue until this can be safely done.

Declaration

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

Parameters

matchName The text string describing the name for this match.
matchSize When 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.
matchAdvertise A bool indicating if this match should be available in NetworkMatch.ListMatches results.
matchPassword A 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.
publicClientAddress The 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.
privateClientAddress The 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.
eloScoreForMatch The 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.
requestDomain The 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.
callback The callback to be called when this function completes. This will be called regardless of whether the function succeeds or fails.

Returns

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

Description

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