Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

371
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda