-
Notifications
You must be signed in to change notification settings - Fork 2
/
LoadScenes.cs
71 lines (66 loc) · 1.64 KB
/
LoadScenes.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;
public class LoadScenes : MonoBehaviour
{
private bool _AsyncLoading = false;
//Load/Reload Scenes
public void LoadScene(int sceneid)
{
SceneManager.LoadScene(sceneid);
}
public void LoadScene(string scenename)
{
SceneManager.LoadScene(scenename);
}
public void ReloadScene()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
public void AsyncReloadScene()
{
if (!_AsyncLoading)
{
_AsyncLoading = true;
StartCoroutine(LoadSceneAsync(SceneManager.GetActiveScene().buildIndex));
}
}
public void AsyncLoadScene(int sceneid)
{
if (!_AsyncLoading)
{
_AsyncLoading = true;
StartCoroutine(LoadSceneAsync(sceneid));
}
}
public void AsyncLoadScene(string scenename)
{
if (!_AsyncLoading)
{
_AsyncLoading = true;
StartCoroutine(LoadSceneAsync(scenename));
}
}
private IEnumerator LoadSceneAsync(string scenename)
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(scenename);
while (!asyncLoad.isDone)
{
yield return null;
}
}
private IEnumerator LoadSceneAsync(int sceneid)
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneid);
while (!asyncLoad.isDone)
{
yield return null;
}
}
//Quit
public void QuitApplication()
{
Application.Quit();
}
}