forked from Unity-Technologies/com.unity.netcode.gameobjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExitButtonScript.cs
More file actions
31 lines (27 loc) · 845 Bytes
/
ExitButtonScript.cs
File metadata and controls
31 lines (27 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using UnityEngine;
using UnityEngine.SceneManagement;
using Unity.Netcode;
public class ExitButtonScript : MonoBehaviour
{
[SerializeField]
private MenuReference m_SceneMenuToLoad;
/// <summary>
/// A very basic way to exit back to the first scene in the build settings
/// </summary>
public void OnExitScene()
{
if (NetworkManager.Singleton)
{
NetworkManager.Singleton.Shutdown();
Destroy(NetworkManager.Singleton.gameObject);
}
if (m_SceneMenuToLoad != null && m_SceneMenuToLoad.GetReferencedScenes()[0] != string.Empty)
{
SceneManager.LoadSceneAsync(m_SceneMenuToLoad.GetReferencedScenes()[0], LoadSceneMode.Single);
}
else
{
SceneManager.LoadSceneAsync(0, LoadSceneMode.Single);
}
}
}