Search Unity

Pause menu not working (uNet matchMaker.DropConnection )

Discussion in 'UNet' started by AtomicCabbage33, Oct 24, 2016.

  1. AtomicCabbage33

    AtomicCabbage33

    Joined:
    Aug 31, 2015
    Posts:
    141
    Hello,

    my pause menu toggles on/off correctly however the 'continue' button which should simply toggle the pause menu off does not do anything when clicked, nor does the 'leave room' button which should drop the connection to the matchmaking server and leave.

    player ui script:

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class PlayerUI : MonoBehaviour {
    4.  
    5.     [SerializeField]
    6.     GameObject pauseMenu;
    7.  
    8.     [SerializeField]
    9.     GameObject scoreboard;
    10.  
    11.  
    12.     void Start ()
    13.     {
    14.         PauseMenu.IsOn = false;
    15.     }
    16.  
    17.     void Update ()
    18.     {
    19.  
    20.         if (Input.GetKeyDown(KeyCode.Escape))
    21.         {
    22.             TogglePauseMenu();
    23.         }
    24.  
    25.         if (Input.GetKeyDown(KeyCode.Tab))
    26.         {
    27.             scoreboard.SetActive(true);
    28.         } else if (Input.GetKeyUp(KeyCode.Tab))
    29.         {
    30.             scoreboard.SetActive(false);
    31.         }
    32.     }
    33.  
    34.     public void TogglePauseMenu ()
    35.     {
    36.         pauseMenu.SetActive(!pauseMenu.activeSelf);
    37.         PauseMenu.IsOn = pauseMenu.activeSelf;
    38.     }
    39.  
    40. }
    41.  
    pause menu script:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Networking;
    3. using UnityEngine.Networking.Match;
    4.  
    5. public class PauseMenu : MonoBehaviour {
    6.  
    7.     public static bool IsOn = false;
    8.  
    9.     private NetworkManager networkManager;
    10.  
    11.     void Start ()
    12.     {
    13.         networkManager = NetworkManager.singleton;
    14.     }
    15.  
    16.     public void LeaveRoom ()
    17.     {
    18.         MatchInfo matchInfo = networkManager.matchInfo;
    19.         networkManager.matchMaker.DropConnection(matchInfo.networkId, matchInfo.nodeId, 0, networkManager.OnDropConnection);
    20.         networkManager.StopHost();
    21.     }
    22.  
    23. }
    24.  
    Picture1.png Picture2.png
     

    Attached Files: