Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
  4. Join us on Thursday, September 29, for a day with Unity's SRP teams here on the forum or on Reddit, and discuss topics around URP, HDRP, and the Scriptable Render Pipeline in general.
    Dismiss Notice

[Solved]How to check match password.

Discussion in 'Multiplayer' started by lesmasamuray, Aug 2, 2018.

  1. lesmasamuray

    lesmasamuray

    Joined:
    Dec 26, 2015
    Posts:
    2
    Hello folks!

    Just wanna know, how do i check if the match password is correct before joining it?
    But i can't find the password option into "match", theres only a bool that returns if the match as or not a password...

    I'm trying to accomplish something like this.

    Thanks!

    Code (CSharp):
    1.  
    2. public void JoinRoom()
    3.  {
    4.      if (match.isPrivate)
    5.      {
    6.          // Does have password
    7.          // Check password
    8.          string tempPassword = password.text;
    9.          if ( match.password == tempPassword)
    10.          {
    11.              // Password is corect
    12.              // Join Room Code here...
    13.          }
    14.          else
    15.          {
    16.              // Password is wrong!
    17.              // Incorrect password code here...
    18.          }
    19.      }
    20.      else
    21.      {
    22.          // Doesn't have password
    23.          // Join room code here...
    24.      }
    25.  }
    26.  
     
  2. lesmasamuray

    lesmasamuray

    Joined:
    Dec 26, 2015
    Posts:
    2
    Figured it out.

    Add this to your NetworkLobbyManager:

    Code (CSharp):
    1. public override void OnMatchJoined(bool success, string extendedInfo, MatchInfo matchInfo)
    2.     {
    3.         base.OnMatchJoined(success, extendedInfo, matchInfo);
    4.         if ( !success )
    5.         {
    6.             // Conection error, incorrect password included
    7.             // Show incorrect password
    8.         }
    9.     }
     
unityunity