Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

How to use MatchAttributes?

Discussion in 'Multiplayer' started by Stratos-Mak, Jun 26, 2015.

  1. Stratos-Mak

    Stratos-Mak

    Joined:
    Aug 14, 2014
    Posts:
    11
    I am creating a game with the matchmaker, and populate it with game name, players etc...
    I want to use the match attributes field to store some more info about the game, as its description suggests.

    Here is how I use it:

    Code (CSharp):
    1.  
    2.         CreateMatchRequest create = new CreateMatchRequest();
    3.         create.name = *name here*
    4.         create.size = *size here*
    5.         create.password = *pass here*
    6.  
    7.         Dictionary<string,long> attributes = new Dictionary<string,long>();
    8.  
    9.         if(create.password == "")
    10.             attributes.Add("pass",0);
    11.         else
    12.             attributes.Add("pass",1);
    13.  
    14.         create.advertise = true;
    15.         create.matchAttributes = attributes;
    16.      
    17.         CreateMatch(create, OnMatchCreate);

    And here is how I parse it when I fetch the game from a client:

    Code (CSharp):
    1.  
    2.         MatchDesc match = matchList[selectedMatch.id];
    3.         long hasPassword=0;
    4.  
    5.         Dictionary<string,long> attributes = match.matchAttributes;
    6.  
    7.         if(attributes.TryGetValue("pass", out hasPassword)) {
    8.  
    9.             if(hasPassword == 0)
    10.                JoinMatch(match.networkId,"",OnMatchJoined);
    11.             else {
    12.                 joinPassPanel.SetActive(true);
    13.             }
    14.         }

    The problem is that the fetched match attributes variable from the MatchDesc object is NULL.

    Am I doing something wrong here ?

    Thanks in advance!
     
  2. hasseyg

    hasseyg

    Joined:
    Nov 16, 2013
    Posts:
    83
    Hi, I am having the same problem
     
  3. Stratos-Mak

    Stratos-Mak

    Joined:
    Aug 14, 2014
    Posts:
    11
    Still no answer :/