Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

365
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda