Method group is Obsolete

NetworkMatch

class in UnityEngine.Networking.Match

/

Hereda de:Behaviour

Cambiar al Manual
Obsolete

Descripción

A component for communicating with the Unity Multiplayer Matchmaking service.

This class aggregates all the supported JSON calls into functions that are callable for games that wish to interact with the MatchMaker service.

The example code below shows how to use NetworkMatch API.

using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.Match;
using System.Collections.Generic;

public class SimpleMatchMaker : MonoBehaviour { void Start() { NetworkManager.singleton.StartMatchMaker(); }

//call this method to request a match to be created on the server public void CreateInternetMatch(string matchName) { NetworkManager.singleton.matchMaker.CreateMatch(matchName, 4, true, "", "", "", 0, 0, OnInternetMatchCreate); }

//this method is called when your request for creating a match is returned private void OnInternetMatchCreate(bool success, string extendedInfo, MatchInfo matchInfo) { if (success) { //Debug.Log("Create match succeeded");

MatchInfo hostInfo = matchInfo; NetworkServer.Listen(hostInfo, 9000);

NetworkManager.singleton.StartHost(hostInfo); } else { Debug.LogError("Create match failed"); } }

//call this method to find a match through the matchmaker public void FindInternetMatch(string matchName) { NetworkManager.singleton.matchMaker.ListMatches(0, 10, matchName, true, 0, 0, OnInternetMatchList); }

//this method is called when a list of matches is returned private void OnInternetMatchList(bool success, string extendedInfo, List<MatchInfoSnapshot> matches) { if (success) { if (matches.Count != 0) { //Debug.Log("A list of matches was returned");

//join the last server (just in case there are two...) NetworkManager.singleton.matchMaker.JoinMatch(matches[matches.Count - 1].networkId, "", "", "", 0, 0, OnJoinInternetMatch); } else { Debug.Log("No matches in requested room!"); } } else { Debug.LogError("Couldn't connect to match maker"); } }

//this method is called when your request to join a match is returned private void OnJoinInternetMatch(bool success, string extendedInfo, MatchInfo matchInfo) { if (success) { //Debug.Log("Able to join a match");

MatchInfo hostInfo = matchInfo; NetworkManager.singleton.StartClient(hostInfo); } else { Debug.LogError("Join match failed"); } } }

Miembros heredados

Variables

enabledEnabled Behaviours are Updated, disabled Behaviours are not.
isActiveAndEnabledHas the Behaviour had active and enabled called?
gameObjectEl game object que tiene este componente adjunto. Un componente siempre está adjunto a un game object.
tagEl tag de este game object.
transformThe Transform attached to this GameObject.

Funciones Públicas

BroadcastMessageLlama al método denominado methodName de todos los MonoBehaviour en este game objecto en cualquiera de sus hijos.
CompareTag¿Este game object está etiquetado con tag?
GetComponentReturns the component of Type type if the GameObject has one attached, null if it doesn't. Will also return disabled components.
GetComponentInChildrenRetorna el componente de tipo type en el GameObject o cualquiera de sus hijos utilizando depth first search (busqueda de profundidad).
GetComponentInParentRetorna el componente de tipo type en el GameObject o cualquiera de sus padres.
GetComponentsRetorna todos los componentes de tipo type en el GameObject.
GetComponentsInChildrenRetorna todos los componentes de tipo type en el GameObject o cualquiera de sus hijo.
GetComponentsInParentRetorna todos los componentes de tipo type en el GameObject o cualquiera de sus padres.
SendMessageLlama al método denominado methodName en cada MonoBehaviour de este game object.
SendMessageUpwardsLlama al método denominado methodName en todos los MonoBehaviour de este juego y en todos los ancestros del behaviour.
TryGetComponentGets the component of the specified type, if it exists.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961