Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Problem with: matchMaker.JoinMatch.

Discussion in 'Multiplayer' started by catalintoader292, Aug 8, 2019.

  1. catalintoader292

    catalintoader292

    Joined:
    Aug 7, 2019
    Posts:
    1
    I started my first multiplayer game and I came across a problem with the matchmaking system that I cannot solve. The following code gives an error on line 86. that looks something like this:
    " Error CS7036 There is no argument given that corresponds to the required formal parameter 'callback' of 'NetworkMatch.JoinMatch(NetworkID, string, string, string, int, int, NetworkMatch.DataResponseDelegate<MatchInfo>)' ".


    JoinGame.cs

    Code (CSharp):
    1. using UnityEngine.UI;
    2. using System.Collections.Generic;
    3. using UnityEngine.Networking;
    4. using UnityEngine.Networking.Match;
    5. using UnityEngine;
    6.  
    7. public class JoinGame : MonoBehaviour
    8. {
    9.  
    10.     List<GameObject> roomList = new List<GameObject>();
    11.  
    12.     [SerializeField]
    13.     private Text status;
    14.  
    15.     [SerializeField]
    16.     private GameObject roomListItemPrefab;
    17.  
    18.     [SerializeField]
    19.     private Transform roomListParent;
    20.  
    21.     private NetworkManager networkManager;
    22.  
    23.     void Start()
    24.     {
    25.         networkManager = NetworkManager.singleton;
    26.         if (networkManager.matchMaker == null)
    27.         {
    28.             networkManager.StartMatchMaker();
    29.         }
    30.  
    31.         RefreshRoomList();
    32.     }
    33.  
    34.     public void RefreshRoomList()
    35.     {
    36.         ClearRoomList();
    37.         networkManager.matchMaker.ListMatches(0, 20, "", false, 0, 0, OnMatchList);
    38.         status.text = "Loading...";
    39.     }
    40.  
    41.     public void OnMatchList(bool succes, string extendedInfo, List<MatchInfoSnapshot> matchlist)
    42.     {
    43.         status.text = "";
    44.  
    45.         if(matchlist == null)
    46.         {
    47.             status.text = "Something went wrong.";
    48.             return;
    49.         }
    50.  
    51.         ClearRoomList();
    52.  
    53.         foreach(MatchInfoSnapshot match in matchlist)
    54.         {
    55.             GameObject _roomListItemGO = Instantiate(roomListItemPrefab);
    56.             _roomListItemGO.transform.SetParent(roomListParent);
    57.  
    58.             RoomListItem _roomListItem = _roomListItemGO.GetComponent<RoomListItem>();
    59.             if(_roomListItem != null)
    60.             {
    61.                 _roomListItem.Setup(match, JoinRoom);
    62.             }
    63.  
    64.             roomList.Add(_roomListItemGO);
    65.         }
    66.  
    67.         if(roomList.Count == 0)
    68.         {
    69.             status.text = "No rooms at the moment.";
    70.         }
    71.     }
    72.  
    73.     void ClearRoomList()
    74.     {
    75.         for (int i = 0; i < roomList.Count; i++)
    76.         {
    77.             Destroy(roomList[i]);
    78.         }
    79.  
    80.         roomList.Clear();
    81.     }
    82.  
    83.  
    84.     public void JoinRoom(MatchInfoSnapshot _match)
    85.     {
    86.         networkManager.matchMaker.JoinMatch(_match.networkId, "", "", 0, 0, networkManager.OnMatchJoined);
    87.         ClearRoomList();
    88.         status.text = "Joining...";
    89.  
    90.     }
    91.  
    92. }
    RoomListItems.cs
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Networking.Match;
    3. using UnityEngine.UI;
    4.  
    5. public class RoomListItem : MonoBehaviour
    6. {
    7.  
    8.     public delegate void JoinRoomDelegate(MatchInfoSnapshot _match);
    9.     private JoinRoomDelegate joinRoomCallback;
    10.  
    11.     [SerializeField]
    12.     private Text roomNameText;
    13.  
    14.     private MatchInfoSnapshot match;
    15.  
    16.     public void Setup(MatchInfoSnapshot _match, JoinRoomDelegate _joinRoomCallback)
    17.     {
    18.         match = _match;
    19.         joinRoomCallback = _joinRoomCallback;
    20.  
    21.         roomNameText.text = match.name + " (" + match.currentSize + "/" + match.maxSize + ")";
    22.     }
    23.  
    24.     public void JoinRoom()
    25.     {
    26.         joinRoomCallback.Invoke(match);
    27.     }
    28.  
    29. }
    The code is taken from a tutorial that is 3 years old, but I am trying to update it as I go.
    Thank you for your help.