-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneLoader.cs
More file actions
49 lines (36 loc) · 1.21 KB
/
SceneLoader.cs
File metadata and controls
49 lines (36 loc) · 1.21 KB
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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneLoader : MonoBehaviour
{
public float scenedelay = 7f;
public int sceneInt = 2;
bool nextSceneLoaded = false;
Scene scene;
void Start()
{
StartCoroutine(StartNextScene());
//StartCoroutine(LoadScener());
}
IEnumerator StartNextScene()
{
// Loads the next Scene (experimental scene) in the background
yield return new WaitForSecondsRealtime(scenedelay);
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneInt, LoadSceneMode.Single);
while (!asyncLoad.isDone)
yield return null;
nextSceneLoaded = true;
}
IEnumerator LoadScener()
{
while(!nextSceneLoaded)
yield return null;
yield return new WaitForSecondsRealtime(scenedelay);
SceneManager.SetActiveScene(SceneManager.GetSceneAt(sceneInt));
//yield return new WaitForSecondsRealtime(scenedelay);
//SceneManager.LoadScene(sceneInt);
//SceneManager.LoadSceneAsync(sceneInt);
}
}