-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLevelLoader.cs
31 lines (28 loc) · 885 Bytes
/
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class LevelLoader : MonoBehaviour
{
public Animator transition;
public float transitionTime = 1f;
public Button Button;
public void OnClicked(Button button)
{
if(button.name == "PlayButton" || button.name == "HighScoreButton"
|| button.name == "CreditButton" || button.name == "TutorialButton" ){
LoadNextLevel();
}
}
public void LoadNextLevel()
{
StartCoroutine(LoadLevel(SceneManager.GetActiveScene().buildIndex + 2));
}
IEnumerator LoadLevel(int levelIndex)
{
transition.SetTrigger("Start");
yield return new WaitForSeconds(transitionTime);
SceneManager.LoadScene(levelIndex);
}
}