Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by thornekey · Mar 04, 2016 at 01:45 PM · c#networkingserverforeachmatchmaking

UNET match making finding but not showing matches..

on my server creator i set up a match like so:

 void Awake() {
         nManager = GetComponent<NetworkManager> ();
         networkMatch = gameObject.AddComponent<NetworkMatch>();
         t_serverCurrentPlayers.text = "0";
     }
 
         //press UI button to trigger this method..
     public void CreateServer() {
         if (serverName.text.Length >= 1 && serverMaxPlayers.text.Length >= 1) {
             CreateMatchRequest newServer = new CreateMatchRequest ();
 
             newServer.name = serverName.text;
             newServer.size = uint.Parse(serverMaxPlayers.text); //100
             newServer.advertise = true;
             
             networkMatch.CreateMatch (newServer, OnServerCreate);
         } else {
             Debug.Log("Please fill in all the required fields!");
         }
     }
 
     public void OnServerCreate(CreateMatchResponse createdServer) {
         if (createdServer.success) {
             serverCreated = true;
             Utility.SetAccessTokenForNetwork(createdServer.networkId, new NetworkAccessToken(createdServer.accessTokenString));
             NetworkServer.Listen(new MatchInfo(createdServer), 9000);
             t_serverCurrentPlayers.text = "0";
 
 
             btn_serverStart.gameObject.SetActive(false);
             btn_serverStop.gameObject.SetActive(true);
             serverName.interactable = false;
             serverMaxPlayers.interactable = false;
             serverPassword.interactable = false;
 
 
                 
 
         } else {
             Debug.Log("Unable to create the server! Please try again!");
         }
     }


and on my client i look for matches and display them like so:

 void Awake() {
         nManager = GetComponent<NetworkManager> ();
 
         if(showDialogBox == null) {
             showDialogBox = GetComponent<ShowDialogBox>();
         }
         networkMatch = gameObject.AddComponent<NetworkMatch>();
     }

     //UI button refreshes the match list here...
     public void ListServers() {
         
         networkMatch.ListMatches (0, 20, "", OnServerListed);
         Debug.Log("list");
 
         Debug.Log(serverList.Count);
         if (serverList.Count > 0) {
             Debug.Log(serverList.Count);
         }
 
         networkMatch.ListMatches (0, 20, "", OnServerListed);
 
         foreach (var server in nManager.matches) {
             Debug.Log("foreach");
             GameObject entry = (GameObject)Instantiate (serverEntry);
             entry.gameObject.transform.FindChild("txt_serverName").GetComponent<Text>().text = server.name;
             entry.gameObject.transform.FindChild("txt_serverCurrPlayers").GetComponent<Text>().text = server.currentSize.ToString();
             entry.gameObject.transform.FindChild("txt_serverMaxPlayers").GetComponent<Text>().text = server.maxSize.ToString();
             entry.gameObject.transform.FindChild("txt_performance").GetComponent<Text>().text = server.averageEloScore.ToString();
 
             if (server.isPrivate) {
                 entry.gameObject.transform.FindChild("img_password").GetComponent<Image>().sprite = privateServer;
             } else { 
                 entry.gameObject.transform.FindChild("img_password").GetComponent<Image>().sprite = publicServer;
             }
             
             entry.transform.SetParent (pnl_serverList);
             Debug.Log("after entry");
             Debug.Log(serverList.Count);
         }
     }
     
     public void OnServerListed(ListMatchResponse serverListResponse) {
         if (serverListResponse.success && serverListResponse.matches != null) {
             networkMatch.JoinMatch(serverListResponse.matches[0].networkId, "", OnServerJoined);
         }
     }
 
     public void OnServerJoined(JoinMatchResponse serverJoin) {
         if (serverJoin.success) {
                         showDialogBox.Show("woo!", "JOINED SERVER!");
         } else {
             showDialogBox.Show("Uh-oh!", "Failed to connect to this server! Please try again!");
         }
     }

UNET makes a msg in the console saying "match.Count == 1" so i assume its finding the match but then it does not display the match (the foreach lines)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Grenadine · Jul 09, 2016 at 08:03 PM

Hello there,

I had the same issue (console showing a matchcount, but matchDesc list returning null) and after fiddling around I came to the conclusion it's a problem of context? I referenced my network manager explicitly when calling Listmatches and then the matchDesc list would be populated again.

In your code that'd be replacing that line

  networkMatch.ListMatches (0, 20, "", OnServerListed);

by this one

 nManager.matchMaker.ListMatches (0, 20, "", nManager.OnServerListed);

I don't understand exactly why is that but that worked for me ^^

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

128 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

Problems with Photon self-hosted server 0 Answers

Looking for basic explanation on unity matchmaker (5.4) and how to use in scripts 0 Answers

What's an acceptable network send rate? 1 Answer

Simple dedicated server on the VDS 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges