I have to click to different buttons to disconnect from servers
In unity when I click the leave button I have to click the leave button and then one of the other buttons for it to leave and it also makes it so i cant rejoin the server here is code help pls
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Photon.Pun;
public class pause : MonoBehaviourPunCallbacks
{
public string mainMenuScene;
public GameObject pauseMenu;
public bool isPaused;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (isPaused)
{
Resume();
}
else
{
isPaused = true;
pauseMenu.SetActive(true);
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
Time.timeScale = 0;
}
}
}
public void Resume()
{
isPaused = false;
pauseMenu.SetActive(false);
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
Time.timeScale = 1;
}
public void Main()
{
SceneManager.LoadScene(0);
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
Time.timeScale = 1;
}
public void Restart()
{
SceneManager.LoadScene(4);
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
Time.timeScale = 1;
}
public void Quit()
{
Application.Quit();
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
Time.timeScale = 1;
}
public void Leave()
{
StartCoroutine(DisconnectAndLoad());
}
IEnumerator DisconnectAndLoad()
{
PhotonNetwork.Disconnect();
while (PhotonNetwork.IsConnected)
yield return null;
SceneManager.LoadScene(0);
Time.timeScale = 1;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}
what do i do?
Answers
-
before leave
after leave
0 -
Apparently, somehow your camera gets destroyed.
We Photonians can't really help with the code (would be nice if you edit the post to mark the code as such). Maybe someone from the community can chime in.
0