Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

364
Views
Unity Mirror Simple Pause UI Not Working in Multiplayer

me and my friend are creating a simple 3D Multiplayer Game. So I coded the game as a single player stand alone and now we are trying to upgrade it to multiplayer. I wrote this simple UI Code.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using Mirror;

public class UI_Interaction : MonoBehaviour
{

    [Header("Cavas")]
    public GameObject PauseMenu;
    public GameObject InGameUI;

    public Button SaveButton;
    [SerializeField]
    private GameObject SceneManager;
    private bool pauseMenuIsActive;
    public GameObject mouseLook;
    
    bool pressed = false;
    float starttime = 0;
    float endtime = 2;

    // Start is called before the first frame update
    void OnStart()
    {
        SceneManager = GameObject.FindGameObjectWithTag("SceneManager");
        SaveButton.onClick.RemoveAllListeners();
        SaveButton.onClick.AddListener(SceneManager.GetComponent<WeaponManager>().SaveGame);
    }

    // Update is called once per frame
    void Update()
    {
        if(starttime >= 0)
        {
            starttime -= Time.deltaTime;
        }

        if(starttime <= 0)
        {
            pressed = false;
        }

        if (Input.GetButton("Pause")
            && !pressed 
            && !this.GetComponent<PlayerHealth>().isDead)
        {
            Cursor.lockState = CursorLockMode.Confined;
            PauseMenu.SetActive(true);
            InGameUI.SetActive(false);
            starttime = endtime;
            pressed = true;
            mouseLook.GetComponent<MouseLook>().enabled = false;
            this.GetComponent<PlayerMovementScript>().enabled = false;
            pauseMenuIsActive = true;
        }
        PauseMenu.SetActive(pauseMenuIsActive);
    }

    public void ResumeGame()
    {
        if (this.GetComponent<NetworkIdentity>().isLocalPlayer) {
            Cursor.lockState = CursorLockMode.Locked;
            PauseMenu.SetActive(false);
            InGameUI.SetActive(true);
            mouseLook.GetComponent<MouseLook>().enabled = true;
            this.GetComponent<PlayerMovementScript>().enabled = true;
            pauseMenuIsActive = false;
        }
    }

    public void EndGame()
    {
        SaveTheGame.Save(FindObjectOfType<WeaponManager>(), FindObjectOfType<MainSceneManager>());
        Application.Quit();
        Debug.LogWarning("Quitting Game");
    }




}

So it works in Singleplayer but when my friend joins my world the UI Pause Menu does no longer disappear on pressing the "Resume" Button. The Button is correctly set up, so this is not the Problem. Also my friend is no longer able to move, when he opens the Menu.

Is there any idea why it is not working? Any help appreciated!

Note: We are both new to Mirror, sorry.

Regards Hannes

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!