-
Notifications
You must be signed in to change notification settings - Fork 0
/
levelloader.cs
59 lines (51 loc) · 1.53 KB
/
levelloader.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
//This class handle the transition of one scene to another.
public class levelloader : MonoBehaviour
{
public Animator transtion;
//This function is called when the user select the setting page.
public void LoadSettings()
{
StartCoroutine(LoadLevel(1));
}
//This function is called when the user select level 1.
public void Load1()
{
StartCoroutine(LoadLevel(2));
}
//This function is called when the user select level 2.
public void Load2()
{
StartCoroutine(LoadLevel(3));
}
//This function is called when the user select level 3.
public void Load3()
{
StartCoroutine(LoadLevel(4));
}
//This function is called when the user select level 4.
public void Load4()
{
StartCoroutine(LoadLevel(5));
}
//This function is called when the back button is pressed to load the home screen.
public void back()
{
StartCoroutine(LoadLevel(0));
}
//This function is callled to load a certain scene with a transition animation.
IEnumerator LoadLevel(int levelIndex)
{
if (setvol.paused == true)
{
Time.timeScale = 1f;
setvol.paused = false;
}
transtion.SetTrigger("Start");
yield return new WaitForSecondsRealtime(1);
SceneManager.LoadScene(levelIndex);
}
}